/** * The argument specifies the lexical representation accepted: * Y specifies a year with optional preceding minus * M specifies a two digit month * D specifies a two digit day of month * t specifies a time (hh:mm:ss.sss) * any other character stands for itself. * All lexical representations are implicitly followed by an optional time zone. */ DateTimeDatatype(String template) { super(makePattern(template)); this.template = template; this.lexicalSpaceKey = makeLexicalSpaceKey(template); }
negative = str.charAt(pos) == '-'; int yearStartIndex = negative ? pos + 1 : pos; pos = skipDigits(str, yearStartIndex); try { year = Integer.parseInt(str.substring(yearStartIndex, pos)); throw createLexicallyInvalidException(); month = parse2Digits(str, pos); pos += 2; break; case 'D': day = parse2Digits(str, pos); pos += 2; break; case 't': hours = parse2Digits(str, pos); pos += 3; minutes = parse2Digits(str, pos); pos += 3; seconds = parse2Digits(str, pos); pos += 2; if (pos < len && str.charAt(pos) == '.') { int end = skipDigits(str, ++pos); for (int j = 0; j < 3; j++) { milliseconds *= 10; int tzOffset; if (hasTimeZone && str.charAt(pos) != 'Z')
public boolean isLessThan(Object obj1, Object obj2) { DateTime dt1 = (DateTime)obj1; DateTime dt2 = (DateTime)obj2; long t1 = dt1.getDate().getTime(); long t2 = dt2.getDate().getTime(); if (dt1.getHasTimeZone() == dt2.getHasTimeZone()) return isLessThan(t1, dt1.getLeapMilliseconds(), t2, dt2.getLeapMilliseconds()); else if (!dt2.getHasTimeZone()) return isLessThan(t1, dt1.getLeapMilliseconds(), t2 - TIME_ZONE_MAX, dt2.getLeapMilliseconds()); else return isLessThan(t1 + TIME_ZONE_MAX, dt1.getLeapMilliseconds(), t2, dt2.getLeapMilliseconds()); }
private static Date createDate(GregorianCalendar cal, int tzOffset, boolean negative, int year, int month, int day, int hours, int minutes, int seconds, int milliseconds) { cal.setLenient(false); cal.setGregorianChange(new Date(Long.MIN_VALUE)); cal.clear(); // Using a time zone of "GMT+XX:YY" doesn't work with JDK 1.1, so we have to do it like this. cal.set(Calendar.ZONE_OFFSET, tzOffset); cal.set(Calendar.DST_OFFSET, 0); cal.set(Calendar.ERA, negative ? GregorianCalendar.BC : GregorianCalendar.AD); // months in ISO8601 start with 1; months in Java start with 0 month -= 1; cal.set(year, month, day, hours, minutes, seconds); cal.set(Calendar.MILLISECOND, milliseconds); checkDate(cal.isLeapYear(year), month, day); // for GCJ return cal.getTime(); }
typeMap.put("dateTime", new DateTimeDatatype("Y-M-DTt")); typeMap.put("time", new DateTimeDatatype("t")); typeMap.put("date", new DateTimeDatatype("Y-M-D")); typeMap.put("gYearMonth", new DateTimeDatatype("Y-M")); typeMap.put("gYear", new DateTimeDatatype("Y")); typeMap.put("gMonthDay", new DateTimeDatatype("--M-D")); typeMap.put("gDay", new DateTimeDatatype("---D")); typeMap.put("gMonth", new DateTimeDatatype("--M"));
negative = str.charAt(pos) == '-'; int yearStartIndex = negative ? pos + 1 : pos; pos = skipDigits(str, yearStartIndex); try { year = Integer.parseInt(str.substring(yearStartIndex, pos)); throw createLexicallyInvalidException(); month = parse2Digits(str, pos); pos += 2; break; case 'D': day = parse2Digits(str, pos); pos += 2; break; case 't': hours = parse2Digits(str, pos); pos += 3; minutes = parse2Digits(str, pos); pos += 3; seconds = parse2Digits(str, pos); pos += 2; if (pos < len && str.charAt(pos) == '.') { int end = skipDigits(str, ++pos); for (int j = 0; j < 3; j++) { milliseconds *= 10; int tzOffset; if (hasTimeZone && str.charAt(pos) != 'Z')
public boolean isLessThan(Object obj1, Object obj2) { DateTime dt1 = (DateTime)obj1; DateTime dt2 = (DateTime)obj2; long t1 = dt1.getDate().getTime(); long t2 = dt2.getDate().getTime(); if (dt1.getHasTimeZone() == dt2.getHasTimeZone()) return isLessThan(t1, dt1.getLeapMilliseconds(), t2, dt2.getLeapMilliseconds()); else if (!dt2.getHasTimeZone()) return isLessThan(t1, dt1.getLeapMilliseconds(), t2 - TIME_ZONE_MAX, dt2.getLeapMilliseconds()); else return isLessThan(t1 + TIME_ZONE_MAX, dt1.getLeapMilliseconds(), t2, dt2.getLeapMilliseconds()); }
private static Date createDate(GregorianCalendar cal, int tzOffset, boolean negative, int year, int month, int day, int hours, int minutes, int seconds, int milliseconds) { cal.setLenient(false); cal.setGregorianChange(new Date(Long.MIN_VALUE)); cal.clear(); // Using a time zone of "GMT+XX:YY" doesn't work with JDK 1.1, so we have to do it like this. cal.set(Calendar.ZONE_OFFSET, tzOffset); cal.set(Calendar.DST_OFFSET, 0); cal.set(Calendar.ERA, negative ? GregorianCalendar.BC : GregorianCalendar.AD); // months in ISO8601 start with 1; months in Java start with 0 month -= 1; cal.set(year, month, day, hours, minutes, seconds); cal.set(Calendar.MILLISECOND, milliseconds); checkDate(cal.isLeapYear(year), month, day); // for GCJ return cal.getTime(); }
typeMap.put("dateTime", new DateTimeDatatype("Y-M-DTt")); typeMap.put("time", new DateTimeDatatype("t")); typeMap.put("date", new DateTimeDatatype("Y-M-D")); typeMap.put("gYearMonth", new DateTimeDatatype("Y-M")); typeMap.put("gYear", new DateTimeDatatype("Y")); typeMap.put("gMonthDay", new DateTimeDatatype("--M-D")); typeMap.put("gDay", new DateTimeDatatype("---D")); typeMap.put("gMonth", new DateTimeDatatype("--M"));
negative = str.charAt(pos) == '-'; int yearStartIndex = negative ? pos + 1 : pos; pos = skipDigits(str, yearStartIndex); try { year = Integer.parseInt(str.substring(yearStartIndex, pos)); throw createLexicallyInvalidException(); month = parse2Digits(str, pos); pos += 2; break; case 'D': day = parse2Digits(str, pos); pos += 2; break; case 't': hours = parse2Digits(str, pos); pos += 3; minutes = parse2Digits(str, pos); pos += 3; seconds = parse2Digits(str, pos); pos += 2; if (pos < len && str.charAt(pos) == '.') { int end = skipDigits(str, ++pos); for (int j = 0; j < 3; j++) { milliseconds *= 10; int tzOffset; if (hasTimeZone && str.charAt(pos) != 'Z')
/** * The argument specifies the lexical representation accepted: * Y specifies a year with optional preceding minus * M specifies a two digit month * D specifies a two digit day of month * t specifies a time (hh:mm:ss.sss) * any other character stands for itself. * All lexical representations are implicitly followed by an optional time zone. */ DateTimeDatatype(String template) { super(makePattern(template)); this.template = template; this.lexicalSpaceKey = makeLexicalSpaceKey(template); }
public boolean isLessThan(Object obj1, Object obj2) { DateTime dt1 = (DateTime)obj1; DateTime dt2 = (DateTime)obj2; long t1 = dt1.getDate().getTime(); long t2 = dt2.getDate().getTime(); if (dt1.getHasTimeZone() == dt2.getHasTimeZone()) return isLessThan(t1, dt1.getLeapMilliseconds(), t2, dt2.getLeapMilliseconds()); else if (!dt2.getHasTimeZone()) return isLessThan(t1, dt1.getLeapMilliseconds(), t2 - TIME_ZONE_MAX, dt2.getLeapMilliseconds()); else return isLessThan(t1 + TIME_ZONE_MAX, dt1.getLeapMilliseconds(), t2, dt2.getLeapMilliseconds()); }
private static Date createDate(GregorianCalendar cal, int tzOffset, boolean negative, int year, int month, int day, int hours, int minutes, int seconds, int milliseconds) { cal.setLenient(false); cal.setGregorianChange(new Date(Long.MIN_VALUE)); cal.clear(); // Using a time zone of "GMT+XX:YY" doesn't work with JDK 1.1, so we have to do it like this. cal.set(Calendar.ZONE_OFFSET, tzOffset); cal.set(Calendar.DST_OFFSET, 0); cal.set(Calendar.ERA, negative ? GregorianCalendar.BC : GregorianCalendar.AD); // months in ISO8601 start with 1; months in Java start with 0 month -= 1; cal.set(year, month, day, hours, minutes, seconds); cal.set(Calendar.MILLISECOND, milliseconds); checkDate(cal.isLeapYear(year), month, day); // for GCJ return cal.getTime(); }
typeMap.put("dateTime", new DateTimeDatatype("Y-M-DTt")); typeMap.put("time", new DateTimeDatatype("t")); typeMap.put("date", new DateTimeDatatype("Y-M-D")); typeMap.put("gYearMonth", new DateTimeDatatype("Y-M")); typeMap.put("gYear", new DateTimeDatatype("Y")); typeMap.put("gMonthDay", new DateTimeDatatype("--M-D")); typeMap.put("gDay", new DateTimeDatatype("---D")); typeMap.put("gMonth", new DateTimeDatatype("--M"));
/** * The argument specifies the lexical representation accepted: * Y specifies a year with optional preceding minus * M specifies a two digit month * D specifies a two digit day of month * t specifies a time (hh:mm:ss.sss) * any other character stands for itself. * All lexical representations are implicitly followed by an optional time zone. */ DateTimeDatatype(String template) { super(makePattern(template)); this.template = template; this.lexicalSpaceKey = makeLexicalSpaceKey(template); }