Skip to content

Instantly share code, notes, and snippets.

@danielnaber
Created October 7, 2014 20:12
Show Gist options
  • Save danielnaber/304c4fea1a000ba8e435 to your computer and use it in GitHub Desktop.
Save danielnaber/304c4fea1a000ba8e435 to your computer and use it in GitHub Desktop.
import java.util.Calendar;
import java.util.Locale;
public class GregorianCalender {
public static void main(String[] args) {
System.out.println("See Java deal with the date the Gregorian calender was introduced:");
printDates(Locale.GERMANY);
printDates(Locale.JAPAN);
}
private static void printDates(Locale locale) {
System.out.println("Locale: " + locale);
Calendar calendar = Calendar.getInstance(locale);
calendar.set(Calendar.YEAR, 1582);
calendar.set(Calendar.MONTH, 9);
calendar.set(Calendar.DAY_OF_MONTH, 2);
for (int i = 0; i < 5; i++) {
calendar.add(Calendar.DAY_OF_MONTH, 1);
System.out.println(calendar.getTime() + " -> " + calendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.GERMAN));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment