In this section, you will learn to convert a long into a date format. Java provides some methods and APIs to solved it.
Description of program:
This example helps you in converting a long value into a Date. The getDateInstance() method is a time formatter with the given formatting style for the default locale. And the getTimeInstance(int style) method is used to get the time formatter with the given formatting style for the default locale. Here style gives the formatting style.
Some other styles are:
[Note: Its value is MEDIUM.]
Here is the code of program:
Output of this program:
C:\date>java LongToDate June 12, 2007
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: June 16, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles