if (m.matches()) { String time = m.group(4); SUTime.IsoDate isoDate = new SUTime.IsoDate(m.group(1), m.group(2), m.group(3)); if (time != null) { SUTime.IsoTime isoTime = new SUTime.IsoTime(m.group(5), m.group(6), m.group(7), m.group(8)); SUTime.IsoDate date = new SUTime.IsoDate(m.group(1), m.group(2), m.group(3)); SUTime.IsoTime time = new SUTime.IsoTime(m.group(4), m.group(5), null); return new SUTime.IsoDateTime(date,time); isoDate = new SUTime.IsoDate(m.group(1), m.group(2), m.group(3)); m = PATTERN_ISO_DATE_2.matcher(dateStr); if (m.matches()) { isoDate = new SUTime.IsoDate(m.group(1), m.group(2), m.group(3)); if (m.matches()) { if (!(m.group(1).equals("XXXX") && m.group(2).equals("XX") && m.group(3).equals("XX"))) { isoDate = new SUTime.IsoDate(m.group(1), m.group(2), m.group(3)); isoDate = new SUTime.IsoDate(m.group(3), m.group(1), m.group(2)); m = PATTERN_ISO_AMBIGUOUS_2.matcher(dateStr); if (m.matches()) { isoDate = new SUTime.IsoDate(m.group(3), m.group(1), m.group(2)); m = PATTERN_ISO_AMBIGUOUS_3.matcher(dateStr); if (m.matches()) { isoDate = new SUTime.IsoDate(m.group(3), m.group(2), m.group(1));
initBase(); if (year < 0 && !PAD_FIELD_UNKNOWN4.equals(y)) { if (Character.isDigit(y.charAt(0)) && Character.isDigit(y.charAt(1))) {
private static void updateTimeZoneNames(Locale locale) { long time1 = new SUTime.IsoDate(2013,1,1).getJodaTimeInstant().getMillis(); long time2 = new SUTime.IsoDate(2013,6,1).getJodaTimeInstant().getMillis(); CollectionValuedMap<String,DateTimeZone> tzMap = new CollectionValuedMap<>(); for (DateTimeZone dtz:TimeZoneIdComponent.timeZonesById.values()) { // standard timezones tzMap.add(dtz.getShortName(time1, locale).toLowerCase(), dtz); tzMap.add(dtz.getName(time1, locale).toLowerCase(), dtz); // Add about half a year to get day light savings timezones... tzMap.add(dtz.getShortName(time2, locale).toLowerCase(), dtz); tzMap.add(dtz.getName(time2, locale).toLowerCase(), dtz); // tzMap.add(dtz.getNameKey(time).toLowerCase(), dtz); // tzMap.add(dtz.getID().toLowerCase(), dtz); } // Order by length for regex List<String> tzNames = new ArrayList<>(tzMap.keySet()); Collections.sort(tzNames, STRING_LENGTH_REV_COMPARATOR); String tzRegex = makeRegex(tzNames); synchronized (TimeZoneComponent.class) { timeZoneNames.put(locale,tzNames); timeZonesByName.put(locale,tzMap); timeZoneRegexes.put(locale,tzRegex); } }
if (m.matches()) { String time = m.group(4); SUTime.IsoDate isoDate = new SUTime.IsoDate(m.group(1), m.group(2), m.group(3)); if (time != null) { SUTime.IsoTime isoTime = new SUTime.IsoTime(m.group(5), m.group(6), m.group(7), m.group(8)); m = p.matcher(dateStr); if (m.matches()) { SUTime.IsoDate date = new SUTime.IsoDate(m.group(1), m.group(2), m.group(3)); SUTime.IsoTime time = new SUTime.IsoTime(m.group(4), m.group(5), null); return new SUTime.IsoDateTime(date,time); m = p.matcher(dateStr); if (m.matches()) { isoDate = new SUTime.IsoDate(m.group(5), m.group(2), m.group(1)); m = p.matcher(dateStr); if (m.matches()) { isoDate = new SUTime.IsoDate(m.group(6), m.group(1), m.group(4)); m = p.matcher(dateStr); if (m.matches()) { isoDate = new SUTime.IsoDate(m.group(1), m.group(2), m.group(3)); m = p.matcher(dateStr); if (m.matches()) { isoDate = new SUTime.IsoDate(m.group(1), m.group(2), m.group(3)); m = p.matcher(dateStr);
if (m.matches()) { String time = m.group(4); SUTime.IsoDate isoDate = new SUTime.IsoDate(m.group(1), m.group(2), m.group(3)); if (time != null) { SUTime.IsoTime isoTime = new SUTime.IsoTime(m.group(5), m.group(6), m.group(7), m.group(8)); SUTime.IsoDate date = new SUTime.IsoDate(m.group(1), m.group(2), m.group(3)); SUTime.IsoTime time = new SUTime.IsoTime(m.group(4), m.group(5), null); return new SUTime.IsoDateTime(date,time); isoDate = new SUTime.IsoDate(m.group(1), m.group(2), m.group(3)); m = PATTERN_ISO_DATE_2.matcher(dateStr); if (m.matches()) { isoDate = new SUTime.IsoDate(m.group(1), m.group(2), m.group(3)); if (m.matches()) { if (!(m.group(1).equals("XXXX") && m.group(2).equals("XX") && m.group(3).equals("XX"))) { isoDate = new SUTime.IsoDate(m.group(1), m.group(2), m.group(3)); isoDate = new SUTime.IsoDate(m.group(3), m.group(1), m.group(2)); m = PATTERN_ISO_AMBIGUOUS_2.matcher(dateStr); if (m.matches()) { isoDate = new SUTime.IsoDate(m.group(3), m.group(1), m.group(2)); m = PATTERN_ISO_AMBIGUOUS_3.matcher(dateStr); if (m.matches()) { isoDate = new SUTime.IsoDate(m.group(3), m.group(2), m.group(1));
if (m.matches()) { String time = m.group(4); SUTime.IsoDate isoDate = new SUTime.IsoDate(m.group(1), m.group(2), m.group(3)); if (time != null) { SUTime.IsoTime isoTime = new SUTime.IsoTime(m.group(5), m.group(6), m.group(7), m.group(8)); SUTime.IsoDate date = new SUTime.IsoDate(m.group(1), m.group(2), m.group(3)); SUTime.IsoTime time = new SUTime.IsoTime(m.group(4), m.group(5), null); return new SUTime.IsoDateTime(date,time); isoDate = new SUTime.IsoDate(m.group(1), m.group(2), m.group(3)); m = PATTERN_ISO_DATE_2.matcher(dateStr); if (m.matches()) { isoDate = new SUTime.IsoDate(m.group(1), m.group(2), m.group(3)); if (m.matches()) { if (!(m.group(1).equals("XXXX") && m.group(2).equals("XX") && m.group(3).equals("XX"))) { isoDate = new SUTime.IsoDate(m.group(1), m.group(2), m.group(3)); isoDate = new SUTime.IsoDate(m.group(3), m.group(1), m.group(2)); m = PATTERN_ISO_AMBIGUOUS_2.matcher(dateStr); if (m.matches()) { isoDate = new SUTime.IsoDate(m.group(3), m.group(1), m.group(2)); m = PATTERN_ISO_AMBIGUOUS_3.matcher(dateStr); if (m.matches()) { isoDate = new SUTime.IsoDate(m.group(3), m.group(2), m.group(1));
initBase(); if (year < 0 && !PAD_FIELD_UNKNOWN4.equals(y)) { if (Character.isDigit(y.charAt(0)) && Character.isDigit(y.charAt(1))) {
initBase(); if (year < 0 && !PAD_FIELD_UNKNOWN4.equals(y)) { if (Character.isDigit(y.charAt(0)) && Character.isDigit(y.charAt(1))) {
initBase(); if (year < 0 && !PAD_FIELD_UNKNOWN4.equals(y)) { if (Character.isDigit(y.charAt(0)) && Character.isDigit(y.charAt(1))) {
String d = (dayGroup >= 0)? results.group(dayGroup):null; if (yearStr != null || m != null || d != null) { isoDate = new SUTime.IsoDate(yearStr, m, d);
private void updateTimeZoneNames(Locale locale) { long time1 = new SUTime.IsoDate(2013,1,1).getJodaTimeInstant().getMillis(); long time2 = new SUTime.IsoDate(2013,6,1).getJodaTimeInstant().getMillis(); CollectionValuedMap<String,DateTimeZone> tzMap = new CollectionValuedMap<String, DateTimeZone>(); for (DateTimeZone dtz:TimeZoneIdComponent.timeZonesById.values()) { // standard timezones tzMap.add(dtz.getShortName(time1, locale).toLowerCase(), dtz); tzMap.add(dtz.getName(time1, locale).toLowerCase(), dtz); // Add about half a year to get day light savings timezones... tzMap.add(dtz.getShortName(time2, locale).toLowerCase(), dtz); tzMap.add(dtz.getName(time2, locale).toLowerCase(), dtz); // tzMap.add(dtz.getNameKey(time).toLowerCase(), dtz); // tzMap.add(dtz.getID().toLowerCase(), dtz); } // Order by length for regex List<String> tzNames = new ArrayList<String>(tzMap.keySet()); Collections.sort(tzNames, STRING_LENGTH_REV_COMPARATOR); String tzRegex = makeRegex(tzNames); synchronized (TimeZoneComponent.class) { timeZoneNames.put(locale,tzNames); timeZonesByName.put(locale,tzMap); timeZoneRegexes.put(locale,tzRegex); } }
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; } }
private static void updateTimeZoneNames(Locale locale) { long time1 = new SUTime.IsoDate(2013,1,1).getJodaTimeInstant().getMillis(); long time2 = new SUTime.IsoDate(2013,6,1).getJodaTimeInstant().getMillis(); CollectionValuedMap<String,DateTimeZone> tzMap = new CollectionValuedMap<>(); for (DateTimeZone dtz:TimeZoneIdComponent.timeZonesById.values()) { // standard timezones tzMap.add(dtz.getShortName(time1, locale).toLowerCase(), dtz); tzMap.add(dtz.getName(time1, locale).toLowerCase(), dtz); // Add about half a year to get day light savings timezones... tzMap.add(dtz.getShortName(time2, locale).toLowerCase(), dtz); tzMap.add(dtz.getName(time2, locale).toLowerCase(), dtz); // tzMap.add(dtz.getNameKey(time).toLowerCase(), dtz); // tzMap.add(dtz.getID().toLowerCase(), dtz); } // Order by length for regex List<String> tzNames = new ArrayList<>(tzMap.keySet()); Collections.sort(tzNames, STRING_LENGTH_REV_COMPARATOR); String tzRegex = makeRegex(tzNames); synchronized (TimeZoneComponent.class) { timeZoneNames.put(locale,tzNames); timeZonesByName.put(locale,tzMap); timeZoneRegexes.put(locale,tzRegex); } }
public void setYear(int y) { this.year = y; initBase(); }
public void setDay(int d) { this.day = d; initBase(); }
public void setYear(int y) { this.year = y; initBase(); }
private static SUTime.IsoDate parseIsoDate(String iso) { Matcher matcher = isoDateFormat.matcher(iso); if (matcher.matches()) { int year = Integer.parseInt(matcher.group(1)); int month = Integer.parseInt(matcher.group(2)); int day = Integer.parseInt(matcher.group(3)); return new SUTime.IsoDate(year, month, day); } else { return null; } } private static Pattern isoYearWeekFormat = Pattern.compile("(\\d\\d\\d\\d)W(\\d\\d)");
public void setDate(int y, int m, int d) { this.year = y; this.month = m; this.day = d; initBase(); }
public void setDay(int d) { this.day = d; initBase(); }
public void setMonth(int m) { this.month = m; initBase(); }