You may need custom serialization in java in may cases. For example, you have legacy java classes which you are not willing to modify for any reason. There can be some design constraints as well. Or even simply, the class is expected to be changed in future releases which could break the deserialization of previously […]
Learn to convert XMLGregorianCalendar to Date class or string value. Also learn to apply timezone changes and daylight saving effects as well.
In this example, we will learn to format XMLGregorianCalendar class to string in multiple patterns e.g. ‘MM/dd/yyyy hh:mm a z’. XMLGregorianCalendar to String in Date/TimeStamp Pattern In below code sample, I am creating instance of XMLGregorianCalendar with current Date object. Then I am formatting it to String format in given pattern. Output: 01/27/2017 01:32 PM […]
To iterate list in java is very basic operation, but over the years it’s gone through some significant changes. We will go through all these changes in given examples.
In this java example, we will learn to convert OutputStream to InputStream which you may need when you read data from one source which return an outputstream; and write/pass the data to other target which wants data in inputstream.
In java, java.util.Locale class represents a specific language and region of the world. If a class varies its behavior according to Locale, it is said to be locale-sensitive. Learn more.
Example of java code to unzip and extract files and sub-directories from a compressed zip file using java.util.zip package.
Learn to use System.getProperty(“user.dir”) and Paths.get(“”).toAbsolutePath() to get current working directory or root folder of the application.
XMLEncoder class is used to serialize or encode a java object into XML file, while XMLDecoder is used to deserialize the xml file back to java object. Learn to use them in detail.
Knowing the difference between Externalizable vs Serializable is important in two aspects, one – if could be asked as an interview question, two – you can use the knowledge to make better informed decision for performance improvement for applying serialization into your application.