Created
October 7, 2014 20:12
-
-
Save danielnaber/304c4fea1a000ba8e435 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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