| Author |
Calendar.getInstance() vs. Calendar.getInstance(Locale.JAPAN)
|
Murly Kant
Greenhorn
Joined: Oct 18, 2010
Posts: 5
|
|
Hello Experts!
I run the following program on my system:
import java.util.Date;
import java.util.Calendar;
import java.util.Locale;
class x{
public static void main(String[] args){
Calendar c = Calendar.getInstance();
Date d = c.getTime();
System.out.println(d);
Calendar c2 = Calendar.getInstance(Locale.JAPAN);
Date d2 = c2.getTime();
System.out.println(d2);
}
}
printing d and d2 gives the same result, I don't understand then whats the difference between two? In which scenario I'll get different result.
Your valuable response will help me to understand the concept.
Thanks & Regards,
|
 |
Pat Farrell
Rancher
Joined: Aug 11, 2007
Posts: 4422
|
|
in Java, a Date or a Calendar does not have a timezone or format. Its simply the number of milliseconds since some particular time. All of the localization, time-zones, etc is done in the Format that helps with the input or output of the Date or Calendar.
Read the Javadocs for SimpleDateFormat for some basics. Its actually a complex problem. The naive implementation of Date within Java, and the sad fact that Date has not been deprecated has hurt many a programmer's productivity.
|
 |
Murly Kant
Greenhorn
Joined: Oct 18, 2010
Posts: 5
|
|
Hello! Pat Farrell, Thanks for your valuable response!
|
 |
 |
|
|
subject: Calendar.getInstance() vs. Calendar.getInstance(Locale.JAPAN)
|
|
|