The Class Date provides you a specific instant in
time( millisecond) precision. This class enabled you to interprets
allowed dates as year, month, day, hour, minute, and second values and
date formatting and parsing of date string.
In this Tutorial we want to describe you a code that helps you in understanding in a Getting Time and Date. For this we have a class 'GetTimeAndDate'.Inside the main method we declared a string variable, formatter and instantiate a date class.
1)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.
2)SimpleDateFormat- is a formatting concrete class that
helps you in parsing date in a locale-sensitive manner. This allows you to
format (date -> text), parsing (text -> date), and normalization.
3)format(date) -This method return you a formatted object to a string and stored in a string variable s.
Finally the System.out .println print the Date, Time and date-time altogether.
GetTimeAndDate.java
|
Date : 03/Nov/2008
|
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Get Time And Date View All Comments
Post your Comment