コード例 #1
0
 void normalizeYear(CalendarDate date) {
   Date ldate = (Date) date;
   // Set the supposed-to-be-correct Gregorian year first
   // e.g., Showa 90 becomes 2015 (1926 + 90 - 1).
   Era era = ldate.getEra();
   if (era == null || !validateEra(era)) {
     ldate.setNormalizedYear(ldate.getYear());
   } else {
     ldate.setNormalizedYear(era.getSinceDate().getYear() + ldate.getYear() - 1);
   }
 }
コード例 #2
0
 public boolean validate(CalendarDate date) {
   Date ldate = (Date) date;
   Era era = ldate.getEra();
   if (era != null) {
     if (!validateEra(era)) {
       return false;
     }
     ldate.setNormalizedYear(era.getSinceDate().getYear() + ldate.getYear());
   } else {
     ldate.setNormalizedYear(ldate.getYear());
   }
   return super.validate(ldate);
 }