Created
August 21, 2017 12:29
-
-
Save MenoData/3714e31977b92aec3ab4910e354d6c88 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 net.time4j.PlainDate; | |
import net.time4j.calendar.*; | |
import net.time4j.format.expert.*; | |
import java.util.Locale; | |
import java.text.ParseException; | |
public class OldJapaneseDate { | |
public static void main(String... args) throws ParseException { | |
ChronoFormatter<JapaneseCalendar> jf = | |
ChronoFormatter.ofPattern("Gy年M月d日", PatternType.CLDR, Locale.JAPANESE, JapaneseCalendar.axis()); | |
String oldJapaneseDate = "慶応4年5月30日"; | |
JapaneseCalendar jcal = jf.parse(oldJapaneseDate); | |
System.out.println(jcal); // Keiō-4(1868)-5-30 (the parsed old japanese date) | |
System.out.println(jcal.transform(PlainDate.axis())); // 1868-07-19 (gregorian western date) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment