Format is an abstract class that is used for formatting local-sensitive information like date, number and message. The Format class derived from the package java.text.format. The Date class is used to a specific instant time in millisecond time.
In this Tutorial we want to describe you a code that helps you to describe Get Time Now. For this we have a class name Get Time Now. Inside the main method we declare a String variable s,Format formatter and instantiate date class. The Simple Date Format display the time in a specific format as passed in argument of variable formatter. The variable formatter call a format method ( ) and pass the date object as argument ,that returns you the current Time in a specified format and store in a string variable, The System.out.println prints the current time from string variable 's'.
Date date = new Date( ) - This is used to instantiate the date class and allocate the memory to a date object, such that it represent the time allocated to it in the nearest millisecond.GetTimeNow.java
Posted on: November 5, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles