Java MinguoChronology parse String like "10/29/0099 1"
import java.time.LocalDate; import java.time.chrono.ChronoLocalDate; import java.time.chrono.Chronology; import java.time.chrono.MinguoChronology; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.format.DecimalStyle; import java.time.temporal.TemporalAccessor; import java.util.Locale; public class Main { public static LocalDate fromString(String text, Chronology chrono) { Locale locale = Locale.getDefault(Locale.Category.FORMAT); String pattern = "M/d/yyyy GGGGG"; DateTimeFormatter df = new DateTimeFormatterBuilder().parseLenient().appendPattern(pattern).toFormatter() .withChronology(chrono).withDecimalStyle(DecimalStyle.of(locale)); TemporalAccessor temporal = df.parse(text); ChronoLocalDate cDate = chrono.date(temporal); return LocalDate.from(cDate); }// www. j a v a 2s. co m public static void main(String[] args) { System.out.printf("%s%n", fromString("10/29/0099 1", MinguoChronology.INSTANCE)); } }