2

I want to set the format for the current date automatically depending on where you are. For example: Germany: day.month.year //Today: 22.12.2015

And if you are in america: month.day.year (Im not sure if its this format but I know its different from others) //Today: 12.22.2015

So the output shall find the right format itself!

What Ive got so far:

private Calendar currentCalender = Calendar.getInstance(Locale.getDefault());
currentCalender.set(Calendar.HOUR_OF_DAY, 0);
currentCalender.set(Calendar.MINUTE, 0);
currentCalender.set(Calendar.SECOND, 0);
currentCalender.set(Calendar.MILLISECOND, 0);
System.out.println(currentCalendar.getTime());

In other forums they said I shall use SimpleFormat with yyyy-MM-dd but thats not what I want because its static and shows the same format for every country.

XxGoliathusxX
  • 922
  • 13
  • 34

1 Answers1

0

To detect where you are, you can use the TimeZone class.

An example:

TimeZone tz = cal.getTimeZone();
// This show the timezone -> tz.getDisplayName();

This way you will know the TimeZone and then the location of your device and the format you should use. Adjust the format according to the value returned by the TimeZone

Virthuss
  • 3,142
  • 1
  • 21
  • 39