List of usage examples for org.joda.time.format DateTimeFormatterBuilder appendOptional
public DateTimeFormatterBuilder appendOptional(DateTimeParser parser)
From source file:org.opendatakit.common.android.utilities.DataUtil.java
License:Apache License
public DataUtil(Locale locale, TimeZone tz) { this.locale = locale; this.tz = DateTimeZone.forTimeZone(tz); DateTimeFormatterBuilder fpBuilder = new DateTimeFormatterBuilder(); for (String pattern : USER_FULL_DATETIME_PATTERNS) { DateTimeFormatter f = DateTimeFormat.forPattern(pattern); fpBuilder.appendOptional(f.getParser()); }/*w ww.java 2 s . co m*/ userFullParser = fpBuilder.toFormatter().withLocale(locale).withZone(this.tz); userPartialParsers = new DateTimeFormatter[USER_PARTIAL_DATETIME_PATTERNS.length]; for (int i = 0; i < USER_PARTIAL_DATETIME_PATTERNS.length; i++) { DateTimeFormatterBuilder dtfb = new DateTimeFormatterBuilder(); for (String pattern : USER_PARTIAL_DATETIME_PATTERNS[i]) { DateTimeFormatter f = DateTimeFormat.forPattern(pattern); dtfb.appendOptional(f.getParser()); } userPartialParsers[i] = dtfb.toFormatter().withLocale(locale).withZone(this.tz); } userShortFormatter = DateTimeFormat.forPattern(USER_SHORT_FORMAT); userLongFormatter = DateTimeFormat.forPattern(USER_LONG_FORMAT); }
From source file:org.opendatakit.utilities.DateUtils.java
License:Apache License
public DateUtils(Locale locale, TimeZone tz) { this.locale = locale; DateTimeZone timeZone = DateTimeZone.forTimeZone(tz); DateTimeFormatterBuilder fpBuilder = new DateTimeFormatterBuilder(); for (String pattern : USER_FULL_DATETIME_PATTERNS) { DateTimeFormatter f = DateTimeFormat.forPattern(pattern); fpBuilder.appendOptional(f.getParser()); }/* w ww .j ava 2s . co m*/ userFullParser = fpBuilder.toFormatter().withLocale(locale).withZone(timeZone); userPartialParsers = new DateTimeFormatter[USER_PARTIAL_DATETIME_PATTERNS.length]; for (int i = 0; i < USER_PARTIAL_DATETIME_PATTERNS.length; i++) { DateTimeFormatterBuilder dtfb = new DateTimeFormatterBuilder(); for (String pattern : USER_PARTIAL_DATETIME_PATTERNS[i]) { DateTimeFormatter f = DateTimeFormat.forPattern(pattern); dtfb.appendOptional(f.getParser()); } userPartialParsers[i] = dtfb.toFormatter().withLocale(locale).withZone(timeZone); } }