@Deprecated // to be removed before 2.0 public static Calendar parseDateFormat(String s, String pattern, TimeZone tz) { return parseDateFormat(s, new SimpleDateFormat(pattern, Locale.ROOT), tz); }
/** * Parses a string using {@link SimpleDateFormat} and a given pattern. The * entire string must match the pattern specified. * * @param s string to be parsed * @param dateFormat Date format * @param tz time zone in which to interpret string. Defaults to the Java * default time zone * @return a Calendar initialized with the parsed value, or null if parsing * failed. If returned, the Calendar is configured to the UTC time zone. */ public static Calendar parseDateFormat(String s, DateFormat dateFormat, TimeZone tz) { ParsePosition pp = new ParsePosition(0); Calendar ret = parseDateFormat(s, dateFormat, tz, pp); if (pp.getIndex() != s.length()) { // Didn't consume entire string - not good return null; } return ret; }
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
@Deprecated // to be removed before 2.0 public static Calendar parseDateFormat(String s, String pattern, TimeZone tz) { return parseDateFormat(s, new SimpleDateFormat(pattern, Locale.ROOT), tz); }
@Deprecated // to be removed before 2.0 public static Calendar parseDateFormat(String s, String pattern, TimeZone tz) { return parseDateFormat(s, new SimpleDateFormat(pattern, Locale.ROOT), tz); }
@Deprecated // to be removed before 2.0 public static Calendar parseDateFormat(String s, String pattern, TimeZone tz) { return parseDateFormat(s, new SimpleDateFormat(pattern, Locale.ROOT), tz); }
@Deprecated // to be removed before 2.0 public static Calendar parseDateFormat(String s, String pattern, TimeZone tz) { return parseDateFormat(s, new SimpleDateFormat(pattern, Locale.ROOT), tz); }
/** * Parses a string using {@link SimpleDateFormat} and a given pattern. The * entire string must match the pattern specified. * * @param s string to be parsed * @param dateFormat Date format * @param tz time zone in which to interpret string. Defaults to the Java * default time zone * @return a Calendar initialized with the parsed value, or null if parsing * failed. If returned, the Calendar is configured to the UTC time zone. */ public static Calendar parseDateFormat(String s, DateFormat dateFormat, TimeZone tz) { ParsePosition pp = new ParsePosition(0); Calendar ret = parseDateFormat(s, dateFormat, tz, pp); if (pp.getIndex() != s.length()) { // Didn't consume entire string - not good return null; } return ret; }
/** * Parses a string using {@link SimpleDateFormat} and a given pattern. The * entire string must match the pattern specified. * * @param s string to be parsed * @param dateFormat Date format * @param tz time zone in which to interpret string. Defaults to the Java * default time zone * @return a Calendar initialized with the parsed value, or null if parsing * failed. If returned, the Calendar is configured to the UTC time zone. */ public static Calendar parseDateFormat(String s, DateFormat dateFormat, TimeZone tz) { ParsePosition pp = new ParsePosition(0); Calendar ret = parseDateFormat(s, dateFormat, tz, pp); if (pp.getIndex() != s.length()) { // Didn't consume entire string - not good return null; } return ret; }
/** * Parses a string using {@link SimpleDateFormat} and a given pattern. The * entire string must match the pattern specified. * * @param s string to be parsed * @param dateFormat Date format * @param tz time zone in which to interpret string. Defaults to the Java * default time zone * @return a Calendar initialized with the parsed value, or null if parsing * failed. If returned, the Calendar is configured to the UTC time zone. */ public static Calendar parseDateFormat(String s, DateFormat dateFormat, TimeZone tz) { ParsePosition pp = new ParsePosition(0); Calendar ret = parseDateFormat(s, dateFormat, tz, pp); if (pp.getIndex() != s.length()) { // Didn't consume entire string - not good return null; } return ret; }
/** * Parses a string using {@link SimpleDateFormat} and a given pattern. The * entire string must match the pattern specified. * * @param s string to be parsed * @param dateFormat Date format * @param tz time zone in which to interpret string. Defaults to the Java * default time zone * @return a Calendar initialized with the parsed value, or null if parsing * failed. If returned, the Calendar is configured to the UTC time zone. */ public static Calendar parseDateFormat(String s, DateFormat dateFormat, TimeZone tz) { ParsePosition pp = new ParsePosition(0); Calendar ret = parseDateFormat(s, dateFormat, tz, pp); if (pp.getIndex() != s.length()) { // Didn't consume entire string - not good return null; } return ret; }
/** * Parses a string using {@link SimpleDateFormat} and a given pattern. The * entire string must match the pattern specified. * * @param s string to be parsed * @param pattern {@link SimpleDateFormat} pattern * @param tz time zone in which to interpret string. Defaults to the Java * default time zone * @return a Calendar initialized with the parsed value, or null if parsing * failed. If returned, the Calendar is configured to the GMT time zone. */ public static Calendar parseDateFormat( String s, String pattern, TimeZone tz) { assert pattern != null; ParsePosition pp = new ParsePosition(0); Calendar ret = parseDateFormat(s, pattern, tz, pp); if (pp.getIndex() != s.length()) { // Didn't consume entire string - not good return null; } return ret; }
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
public static SqlDateLiteral parseDateLiteral(String s, SqlParserPos pos) { final String dateStr = parseString(s); final Calendar cal = DateTimeUtils.parseDateFormat(dateStr, Format.PER_THREAD.get().date, DateTimeUtils.UTC_ZONE); if (cal == null) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("DATE", s, RESOURCE.badFormat(DateTimeUtils.DATE_FORMAT_STRING).str())); } final DateString d = DateString.fromCalendarFields(cal); return SqlLiteral.createDate(d, pos); }
public static SqlDateLiteral parseDateLiteral(String s, SqlParserPos pos) { final String dateStr = parseString(s); final Calendar cal = DateTimeUtils.parseDateFormat(dateStr, Format.PER_THREAD.get().date, DateTimeUtils.UTC_ZONE); if (cal == null) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("DATE", s, RESOURCE.badFormat(DateTimeUtils.DATE_FORMAT_STRING).str())); } final DateString d = DateString.fromCalendarFields(cal); return SqlLiteral.createDate(d, pos); }
SqlDateLiteral parseDateLiteral(String s, SqlParserPos pos) throws ParseException { String dateStr = SqlParserUtil.parseString(s); Calendar cal = DateTimeUtils.parseDateFormat( dateStr, DateTimeUtils.DATE_FORMAT_STRING, DateTimeUtils.GMT_ZONE); if (null == cal) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("DATE", s, RESOURCE.badFormat(DateTimeUtils.DATE_FORMAT_STRING).str())); } return SqlLiteral.createDate(cal, pos); }
SqlDateLiteral parseDateLiteral(String s, SqlParserPos pos) throws ParseException { String dateStr = SqlParserUtil.parseString(s); Calendar cal = DateTimeUtils.parseDateFormat( dateStr, DateTimeUtils.DATE_FORMAT_STRING, DateTimeUtils.GMT_ZONE); if (null == cal) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("DATE", s, RESOURCE.badFormat(DateTimeUtils.DATE_FORMAT_STRING).str())); } return SqlLiteral.createDate(cal, pos); }
new SimpleDateFormat(DateTimeUtils.DATE_FORMAT_STRING, Locale.ROOT); final Calendar c = DateTimeUtils.parseDateFormat("1234-04-12", formatD, DateTimeUtils.UTC_ZONE); assertThat(c, notNullValue());
new SimpleDateFormat(DateTimeUtils.DATE_FORMAT_STRING, Locale.ROOT); final Calendar c = DateTimeUtils.parseDateFormat("1234-04-12", formatD, DateTimeUtils.UTC_ZONE); assertThat(c, notNullValue());
SqlDateLiteral parseDateLiteral(String s, SqlParserPos pos) throws ParseException { String dateStr = SqlParserUtil.parseString(s); Calendar cal = DateTimeUtils.parseDateFormat( dateStr, DateTimeUtils.DATE_FORMAT_STRING, DateTimeUtils.GMT_ZONE); if (null == cal) { throw SqlUtil.newContextException(pos, RESOURCE.illegalLiteral("DATE", s, RESOURCE.badFormat(DateTimeUtils.DATE_FORMAT_STRING).str())); } return SqlLiteral.createDate(cal, pos); }