I want to get local Date from windows. this date depends on what
windows is installed(English, German).
For Example: English windows time: 3/18/08 9:21 AM
That would be American format, we English prefer our dates in sequential order
rather than inside-out order.
German windows time: 18.03.08 09:22
How can I get this Date?
Use DateFormat and Local.
For example:
package tests;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
public class FormatDate {
public static void main(String[] args) {
Locale american = new Locale("en", "US" );
Locale german = new Locale("de", "DE");
DateFormat americanFormat =
DateFormat.getDateInstance(DateFormat.SHORT, american);
DateFormat germanFormat =
DateFormat.getDateInstance(DateFormat.SHORT, german);
Date date = new Date();
System.out.println(americanFormat.format(date));
System.out.println(germanFormat.format(date));
}
}
will produce the following output:
3/18/08
18.03.08
As for getting the time, I'll leave that as an exercise for the student...