Home » Core Java » text » Page 2

text

Format date in default formats with DateFormat

With this example we are going to demonstrate how to format a date in default formats with DateFormat. Default formats are provided by the DateFormat API to control the length of the result, from SHORT, MEDIUM to LONG and FULL. In short, to format a date in default formats with DateFormat you should: Create a new Date. For each one ...

Read More »

Convert String to Date with DateFormat

This is an example of how to convert a String to Date with DateFormat. As the Java API documentation states Date formats are not synchronized, so it is recommended to create separate format instances for each thread. Below are three examples of creating separate instances of DateFormat. The “getDateInstance(..)” approach implies that you should invoke the getDateInstance(int style) API method, ...

Read More »