I was going through the different ways that we can get Date and Time in java, while reading the documentation could not understand what the below quote mean.
Unfortunately, the API for these functions was not amenable to internationalization.
The above quote is from documentation of Date class of java. What does that mean ?? Is this the reason why the methods of the Date class were deprecated?
tl;dr
Use only java.time classes. Never use
Date/Calendaretc.Avoid legacy date-time classes
You asked:
The legacy date-time classes are rife with poor design decisions, written by people who did not understand date-time handling. The lack of internationalization is but one of many problems.
Trying to understand these legacy classes is a waste of time, unless you want lessons on how to not do proper object-oriented programming. These classes were years ago supplanted by the modern java.time classes defined in JSR 310.
Use neither of the two
Dateclasses, norCalendar,SimpleDateFormat,GregorianCalendar, etc. Use only the date-time classes from the java.time package. Focus your precious learning time on java.time.java.time
The java.time classes provide internationalization through the
DateTimeFormatterclass.In modern Java, the localization information comes from the Common Locale Data Repository Project (CLDR) published by the Unicode Consortium.
Here is some example code.
Capture the current moment as seen in the wall-clock time/calendar used by the people of Japan. For this purpose, use
ZonedDateTimeclass. Specify the time zone of interest by using theZoneIdclass.Generate text representing that moment using French Canadian localization (human language & cultural norms).
Dump to console.
When run: