Refine search
DateFormat dateFormat, TimeZone tz, int maxPrecision) { final ParsePosition pp = new ParsePosition(0); final Calendar cal = parseDateFormat(s, dateFormat, tz, pp); if (cal == null) { return null; // Invalid date/time format return new PrecisionTime(cal, secFraction, p);
new SimpleDateFormat(DateTimeUtils.DATE_FORMAT_STRING, Locale.ROOT); final Calendar c = DateTimeUtils.parseDateFormat("1234-04-12", formatD, DateTimeUtils.UTC_ZONE); assertThat(c, notNullValue()); Locale.ROOT); final DateTimeUtils.PrecisionTime pt = DateTimeUtils.parsePrecisionDateTimeLiteral( "1234-04-12 01:23:45.06789", formatTs, DateTimeUtils.UTC_ZONE, -1); assertThat(pt, notNullValue()); assertThat(pt.getCalendar().get(Calendar.YEAR), is(1234)); assertThat(pt.getCalendar().get(Calendar.MONTH), is(Calendar.APRIL)); assertThat(pt.getCalendar().get(Calendar.DAY_OF_MONTH), is(12)); assertThat(pt.getCalendar().get(Calendar.HOUR_OF_DAY), is(1)); assertThat(pt.getCalendar().get(Calendar.MINUTE), is(23)); assertThat(pt.getCalendar().get(Calendar.SECOND), is(45)); assertThat(pt.getCalendar().get(Calendar.MILLISECOND), is(67)); assertThat(pt.getFraction(), is("06789")); assertThat(pt.getPrecision(), is(5)); DateTimeUtils.parsePrecisionDateTimeLiteral( "1234-04-12 01:23:45.06789", formatTs, DateTimeUtils.UTC_ZONE, 2); assertThat(pt2, notNullValue()); assertThat(pt2.getCalendar().get(Calendar.MILLISECOND), is(60)); assertThat(pt2.getFraction(), is("06"));
DateTimeUtils.parsePrecisionDateTimeLiteral(v, new SimpleDateFormat(DateTimeUtils.TIME_FORMAT_STRING, Locale.ROOT), this.timeZone, -1); pt.getCalendar().setTimeZone(timeZone); if (fraction != null) { return new TimeWithTimeZoneString( pt.getCalendar().get(Calendar.HOUR_OF_DAY), pt.getCalendar().get(Calendar.MINUTE), pt.getCalendar().get(Calendar.SECOND), timeZone.getID()) .withFraction(fraction); pt.getCalendar().get(Calendar.HOUR_OF_DAY), pt.getCalendar().get(Calendar.MINUTE), pt.getCalendar().get(Calendar.SECOND), timeZone.getID());
new SimpleDateFormat(DateTimeUtils.DATE_FORMAT_STRING, Locale.ROOT); final Calendar c = DateTimeUtils.parseDateFormat("1234-04-12", formatD, DateTimeUtils.UTC_ZONE); assertThat(c, notNullValue()); Locale.ROOT); final DateTimeUtils.PrecisionTime pt = DateTimeUtils.parsePrecisionDateTimeLiteral( "1234-04-12 01:23:45.06789", formatTs, DateTimeUtils.UTC_ZONE, -1); assertThat(pt, notNullValue()); assertThat(pt.getCalendar().get(Calendar.YEAR), is(1234)); assertThat(pt.getCalendar().get(Calendar.MONTH), is(Calendar.APRIL)); assertThat(pt.getCalendar().get(Calendar.DAY_OF_MONTH), is(12)); assertThat(pt.getCalendar().get(Calendar.HOUR_OF_DAY), is(1)); assertThat(pt.getCalendar().get(Calendar.MINUTE), is(23)); assertThat(pt.getCalendar().get(Calendar.SECOND), is(45)); assertThat(pt.getCalendar().get(Calendar.MILLISECOND), is(67)); assertThat(pt.getFraction(), is("06789")); assertThat(pt.getPrecision(), is(5)); DateTimeUtils.parsePrecisionDateTimeLiteral( "1234-04-12 01:23:45.06789", formatTs, DateTimeUtils.UTC_ZONE, 2); assertThat(pt2, notNullValue()); assertThat(pt2.getCalendar().get(Calendar.MILLISECOND), is(60)); assertThat(pt2.getFraction(), is("06"));
DateTimeUtils.parsePrecisionDateTimeLiteral(v, new SimpleDateFormat(DateTimeUtils.TIME_FORMAT_STRING, Locale.ROOT), this.timeZone, -1); pt.getCalendar().setTimeZone(timeZone); if (fraction != null) { return new TimeWithTimeZoneString( pt.getCalendar().get(Calendar.HOUR_OF_DAY), pt.getCalendar().get(Calendar.MINUTE), pt.getCalendar().get(Calendar.SECOND), timeZone.getID()) .withFraction(fraction); pt.getCalendar().get(Calendar.HOUR_OF_DAY), pt.getCalendar().get(Calendar.MINUTE), pt.getCalendar().get(Calendar.SECOND), timeZone.getID());
switch (typeName) { case DATE: final Calendar cal = DateTimeUtils.parseDateFormat(literal, new SimpleDateFormat(format, Locale.ROOT), tz); DateTimeUtils.parsePrecisionDateTimeLiteral(literal, new SimpleDateFormat(format, Locale.ROOT), tz, -1); if (ts == null) { v = TimestampString.fromCalendarFields(ts.getCalendar()) .withFraction(ts.getFraction()); break; case TIME: v = TimeString.fromCalendarFields(ts.getCalendar()) .withFraction(ts.getFraction()); break; default:
DateTimeUtils.parsePrecisionDateTimeLiteral(v, new SimpleDateFormat(DateTimeUtils.TIMESTAMP_FORMAT_STRING, Locale.ROOT), this.timeZone, -1); pt.getCalendar().setTimeZone(timeZone); if (fraction != null) { return new TimestampWithTimeZoneString( pt.getCalendar().get(Calendar.YEAR), pt.getCalendar().get(Calendar.MONTH) + 1, pt.getCalendar().get(Calendar.DAY_OF_MONTH), pt.getCalendar().get(Calendar.HOUR_OF_DAY), pt.getCalendar().get(Calendar.MINUTE), pt.getCalendar().get(Calendar.SECOND), timeZone.getID()) .withFraction(fraction); pt.getCalendar().get(Calendar.YEAR), pt.getCalendar().get(Calendar.MONTH) + 1, pt.getCalendar().get(Calendar.DAY_OF_MONTH), pt.getCalendar().get(Calendar.HOUR_OF_DAY), pt.getCalendar().get(Calendar.MINUTE), pt.getCalendar().get(Calendar.SECOND), timeZone.getID());
assert pattern != null; ParsePosition pp = new ParsePosition(0); Calendar cal = parseDateFormat(s, pattern, tz, pp); if (cal == null) { return null; // Invalid date/time format PrecisionTime ret = new PrecisionTime(cal, p); return ret;
switch (typeName) { case DATE: final Calendar cal = DateTimeUtils.parseDateFormat(literal, new SimpleDateFormat(format, Locale.ROOT), tz); DateTimeUtils.parsePrecisionDateTimeLiteral(literal, new SimpleDateFormat(format, Locale.ROOT), tz, -1); if (ts == null) { v = TimestampString.fromCalendarFields(ts.getCalendar()) .withFraction(ts.getFraction()); break; case TIME: v = TimeString.fromCalendarFields(ts.getCalendar()) .withFraction(ts.getFraction()); break; default:
DateTimeUtils.parsePrecisionDateTimeLiteral(v, new SimpleDateFormat(DateTimeUtils.TIMESTAMP_FORMAT_STRING, Locale.ROOT), this.timeZone, -1); pt.getCalendar().setTimeZone(timeZone); if (fraction != null) { return new TimestampWithTimeZoneString( pt.getCalendar().get(Calendar.YEAR), pt.getCalendar().get(Calendar.MONTH) + 1, pt.getCalendar().get(Calendar.DAY_OF_MONTH), pt.getCalendar().get(Calendar.HOUR_OF_DAY), pt.getCalendar().get(Calendar.MINUTE), pt.getCalendar().get(Calendar.SECOND), timeZone.getID()) .withFraction(fraction); pt.getCalendar().get(Calendar.YEAR), pt.getCalendar().get(Calendar.MONTH) + 1, pt.getCalendar().get(Calendar.DAY_OF_MONTH), pt.getCalendar().get(Calendar.HOUR_OF_DAY), pt.getCalendar().get(Calendar.MINUTE), pt.getCalendar().get(Calendar.SECOND), timeZone.getID());
DateFormat dateFormat, TimeZone tz, int maxPrecision) { final ParsePosition pp = new ParsePosition(0); final Calendar cal = parseDateFormat(s, dateFormat, tz, pp); if (cal == null) { return null; // Invalid date/time format return new PrecisionTime(cal, secFraction, p);
public static SqlTimeLiteral parseTimeLiteral(String s, SqlParserPos pos) { final String dateStr = parseString(s); final DateTimeUtils.PrecisionTime pt = DateTimeUtils.parsePrecisionDateTimeLiteral(dateStr, Format.PER_THREAD.get().time, DateTimeUtils.UTC_ZONE, -1); if (pt == null) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("TIME", s, RESOURCE.badFormat(DateTimeUtils.TIME_FORMAT_STRING).str())); } final TimeString t = TimeString.fromCalendarFields(pt.getCalendar()) .withFraction(pt.getFraction()); return SqlLiteral.createTime(t, pt.getPrecision(), pos); }
DateFormat dateFormat, TimeZone tz, int maxPrecision) { final ParsePosition pp = new ParsePosition(0); final Calendar cal = parseDateFormat(s, dateFormat, tz, pp); if (cal == null) { return null; // Invalid date/time format return new PrecisionTime(cal, secFraction, p);
public static SqlTimeLiteral parseTimeLiteral(String s, SqlParserPos pos) { final String dateStr = parseString(s); final DateTimeUtils.PrecisionTime pt = DateTimeUtils.parsePrecisionDateTimeLiteral(dateStr, Format.PER_THREAD.get().time, DateTimeUtils.UTC_ZONE, -1); if (pt == null) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("TIME", s, RESOURCE.badFormat(DateTimeUtils.TIME_FORMAT_STRING).str())); } final TimeString t = TimeString.fromCalendarFields(pt.getCalendar()) .withFraction(pt.getFraction()); return SqlLiteral.createTime(t, pt.getPrecision(), pos); }
DateFormat dateFormat, TimeZone tz, int maxPrecision) { final ParsePosition pp = new ParsePosition(0); final Calendar cal = parseDateFormat(s, dateFormat, tz, pp); if (cal == null) { return null; // Invalid date/time format return new PrecisionTime(cal, secFraction, p);
public static SqlTimestampLiteral parseTimestampLiteral(String s, SqlParserPos pos) { final String dateStr = parseString(s); final DateTimeUtils.PrecisionTime pt = DateTimeUtils.parsePrecisionDateTimeLiteral(dateStr, Format.PER_THREAD.get().timestamp, DateTimeUtils.UTC_ZONE, -1); if (pt == null) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("TIMESTAMP", s, RESOURCE.badFormat(DateTimeUtils.TIMESTAMP_FORMAT_STRING).str())); } final TimestampString ts = TimestampString.fromCalendarFields(pt.getCalendar()) .withFraction(pt.getFraction()); return SqlLiteral.createTimestamp(ts, pt.getPrecision(), pos); }
DateFormat dateFormat, TimeZone tz, int maxPrecision) { final ParsePosition pp = new ParsePosition(0); final Calendar cal = parseDateFormat(s, dateFormat, tz, pp); if (cal == null) { return null; // Invalid date/time format return new PrecisionTime(cal, secFraction, p);
public static SqlTimestampLiteral parseTimestampLiteral(String s, SqlParserPos pos) { final String dateStr = parseString(s); final DateTimeUtils.PrecisionTime pt = DateTimeUtils.parsePrecisionDateTimeLiteral(dateStr, Format.PER_THREAD.get().timestamp, DateTimeUtils.UTC_ZONE, -1); if (pt == null) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("TIMESTAMP", s, RESOURCE.badFormat(DateTimeUtils.TIMESTAMP_FORMAT_STRING).str())); } final TimestampString ts = TimestampString.fromCalendarFields(pt.getCalendar()) .withFraction(pt.getFraction()); return SqlLiteral.createTimestamp(ts, pt.getPrecision(), pos); }
SqlTimestampLiteral parseTimestampLiteral(String s, SqlParserPos pos) throws ParseException { String dateStr = SqlParserUtil.parseString(s); DateTimeUtils.PrecisionTime pt = DateTimeUtils.parsePrecisionDateTimeLiteral( dateStr, DateTimeUtils.TIMESTAMP_FORMAT_STRING, DateTimeUtils.GMT_ZONE); if (null == pt) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("TIMESTAMP", s, RESOURCE.badFormat(DateTimeUtils.TIMESTAMP_FORMAT_STRING).str())); } return SqlLiteral.createTimestamp(pt.getCalendar(), pt.getPrecision(), pos); }
SqlTimeLiteral parseTimeLiteral(String s, SqlParserPos pos) throws ParseException { String dateStr = SqlParserUtil.parseString(s); DateTimeUtils.PrecisionTime pt = DateTimeUtils.parsePrecisionDateTimeLiteral( dateStr, DateTimeUtils.TIME_FORMAT_STRING, DateTimeUtils.GMT_ZONE); if (null == pt) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("TIME", s, RESOURCE.badFormat(DateTimeUtils.TIME_FORMAT_STRING).str())); } return SqlLiteral.createTime(pt.getCalendar(), pt.getPrecision(), pos); }