final SimpleDateFormat parser = new SimpleDateFormat(timeFormat); final SimpleDateFormat formatter = new SimpleDateFormat(resultFormat); parser.setLenient(true);
@Override public void setLenient(boolean lenient) { fIcuSdf.setLenient(lenient); }
@JsonCreator public TimeDimExtractionFn( @JsonProperty("timeFormat") String timeFormat, @JsonProperty("resultFormat") String resultFormat ) { this.timeFormat = timeFormat; this.timeFormatter = new SimpleDateFormat(timeFormat); this.timeFormatter.setLenient(true); this.resultFormat = resultFormat; this.resultFormatter = new SimpleDateFormat(resultFormat); }
@JsonCreator public TimeDimExtractionFn( @JsonProperty("timeFormat") String timeFormat, @JsonProperty("resultFormat") String resultFormat ) { Preconditions.checkNotNull(timeFormat, "timeFormat must not be null"); Preconditions.checkNotNull(resultFormat, "resultFormat must not be null"); this.timeFormat = timeFormat; this.timeFormatter = ThreadLocal.withInitial(() -> { SimpleDateFormat formatter = new SimpleDateFormat(TimeDimExtractionFn.this.timeFormat); formatter.setLenient(true); return formatter; }); this.resultFormat = resultFormat; this.resultFormatter = ThreadLocal.withInitial(() -> { SimpleDateFormat formatter = new SimpleDateFormat(TimeDimExtractionFn.this.resultFormat); return formatter; }); }
private final SimpleDateFormat getDateFormat(Locale locale, Convertor.FormatCache formatCache) { SimpleDateFormat dateFormat = null; if (formatCache != null) dateFormat = (SimpleDateFormat)formatCache.get(); if (dateFormat == null) { dateFormat = getDateFormat(locale); if (formatCache != null) formatCache.store(dateFormat); } dateFormat.setLenient(lenient); return dateFormat; }
protected SimpleDateFormat getDateFormat(Locale locale) { SimpleDateFormat dateFormat = null; if (this.variant.equals(DATE)) { //dateFormat = I18nSupport.getInstance().getDateFormat(style, locale); dateFormat = (SimpleDateFormat)DateFormat.getDateInstance(style, locale); } else if (this.variant.equals(TIME)) { //dateFormat = I18nSupport.getInstance().getTimeFormat(style, locale); dateFormat = (SimpleDateFormat)DateFormat.getTimeInstance(style, locale); } else if (this.variant.equals(DATE_TIME)) { //dateFormat = I18nSupport.getInstance().getDateTimeFormat(style, style, locale); dateFormat = (SimpleDateFormat)DateFormat.getDateTimeInstance(style, style, locale); } String pattern = (String)localizedPatterns.get(locale); if (pattern != null) // Note: this was previously using applyLocalizedPattern() which allows to use // a locale-specific pattern syntax, e.g. in french "j" (jour) for "d" and // "a" (annee) for "y". But the localized pattern syntax is very little known and thus // led to some weird pattern syntax error messages. dateFormat.applyPattern(pattern); else if (nonLocalizedPattern != null) dateFormat.applyPattern(nonLocalizedPattern); dateFormat.setLenient(lenient); return dateFormat; }
final SimpleDateFormat parser = new SimpleDateFormat(timeFormat); final SimpleDateFormat formatter = new SimpleDateFormat(resultFormat); parser.setLenient(true);