コード例 #1
0
 public SUTime.Temporal apply(String text) {
   // TODO: TIMEZONE?
   DateTime dateTime = null;
   try {
     dateTime = formatter.parseDateTime(text);
   } catch (org.joda.time.IllegalFieldValueException e) {
     logger.warning(
         "WARNING: Invalid temporal \""
             + text
             + "\" ("
             + e.getMessage()
             + "). Skipping and continuing...");
     return null;
   }
   assert (dateTime != null);
   if (hasDate && hasTime) {
     return new SUTime.GroundedTime(dateTime);
     //        return new SUTime.IsoDateTime( new SUTime.IsoTime(dateTime.getHourOfDay(),
     // dateTime.getMinuteOfHour(), dateTime.getSecondOfMinute());
     //        Date d = new SUTime.IsoDate(dateTime.getYear(), dateTime.getMonthOfYear(),
     // dateTime.getDayOfMonth()) );
   } else if (hasTime) {
     // TODO: Millisecs?
     return new SUTime.IsoTime(
         dateTime.getHourOfDay(), dateTime.getMinuteOfHour(), dateTime.getSecondOfMinute());
   } else if (hasDate) {
     return new SUTime.IsoDate(
         dateTime.getYear(), dateTime.getMonthOfYear(), dateTime.getDayOfMonth());
   } else {
     return null;
   }
 }
コード例 #2
0
 protected SUTime.Temporal extract(MatchResult results) {
   try {
     return tempFunc.apply(results);
   } catch (org.joda.time.IllegalFieldValueException e) {
     logger.warning(
         "WARNING: found invalid temporal expression: \""
             + e.getMessage()
             + "\". Will discard it...");
     return null;
   }
 }