thread269-1703513
What is the best way to store a simple date.
Should I just store it as a String or should I go through the process of using java.util.calendar or something similar?
I found this code on the internet and is a good example to work with dates
What is the best way to store a simple date.
Should I just store it as a String or should I go through the process of using java.util.calendar or something similar?
I found this code on the internet and is a good example to work with dates
Code:
import java.util.Calendar;
import java.util.Date;
public class GetTheCurrentTime {
public static void main( String[] args ) {
// one way
long currentTimeInMillis = System.currentTimeMillis();
Date today = new Date( currentTimeInMillis );
System.out.println( today );
// another way
Calendar cal = Calendar.getInstance();
today = cal.getTime();
System.out.println( today );
}
}