List of usage examples for org.joda.time.format DateTimeFormatterBuilder DateTimeFormatterBuilder
public DateTimeFormatterBuilder()
From source file:dk.teachus.frontend.utils.Formatters.java
License:Apache License
public static DateTimeFormatter getFormatMonth() { return new DateTimeFormatterBuilder().appendMonthOfYearText().appendLiteral(", ") //$NON-NLS-1$ .appendYear(4, 4).toFormatter().withLocale(Session.get().getLocale()); }
From source file:dk.teachus.frontend.utils.Formatters.java
License:Apache License
public static DateTimeFormatter getFormatOnlyMonth() { return new DateTimeFormatterBuilder().appendMonthOfYearText().toFormatter() .withLocale(Session.get().getLocale()); }
From source file:dk.teachus.frontend.utils.Formatters.java
License:Apache License
public static DateTimeFormatter getFormatWeekOfYear() { return new DateTimeFormatterBuilder().appendLiteral(TeachUsSession.get().getString("Formatters.week")) //$NON-NLS-1$ .appendLiteral(" ") //$NON-NLS-1$ .appendWeekOfWeekyear(1).appendLiteral(", ") //$NON-NLS-1$ .appendYear(4, 4).toFormatter().withLocale(Session.get().getLocale()); }
From source file:io.datenwelt.cargo.rest.serialization.DateTimeDeserializer.java
License:Apache License
public DateTimeDeserializer() { super(Date.class); DateTimeParser[] parsers = { DateTimeFormat.forPattern("YYYY-MM-dd'T'hh:mm:ss.SSSZ").getParser(), DateTimeFormat.forPattern("YYYY-MM-dd'T'hh:mm:ssZ").getParser() }; FORMAT = new DateTimeFormatterBuilder().append(null, parsers).toFormatter(); }
From source file:io.datenwelt.cargo.rest.serialization.LocalTimeDeserializer.java
License:Apache License
public LocalTimeDeserializer() { super(LocalTime.class); DateTimeParser[] parsers = { DateTimeFormat.forPattern("hh:mm:ss.SSS").getParser(), DateTimeFormat.forPattern("hh:mm:ss").getParser(), }; FORMAT = new DateTimeFormatterBuilder().append(null, parsers).toFormatter(); }
From source file:io.prestosql.operator.scalar.DateTimeFunctions.java
License:Apache License
@SuppressWarnings("fallthrough") public static DateTimeFormatter createDateTimeFormatter(Slice format) { DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder(); String formatString = format.toStringUtf8(); boolean escaped = false; for (int i = 0; i < format.length(); i++) { char character = formatString.charAt(i); if (escaped) { switch (character) { case 'a': // %a Abbreviated weekday name (Sun..Sat) builder.appendDayOfWeekShortText(); break; case 'b': // %b Abbreviated month name (Jan..Dec) builder.appendMonthOfYearShortText(); break; case 'c': // %c Month, numeric (0..12) builder.appendMonthOfYear(1); break; case 'd': // %d Day of the month, numeric (00..31) builder.appendDayOfMonth(2); break; case 'e': // %e Day of the month, numeric (0..31) builder.appendDayOfMonth(1); break; case 'f': // %f Microseconds (000000..999999) builder.appendFractionOfSecond(6, 9); break; case 'H': // %H Hour (00..23) builder.appendHourOfDay(2); break; case 'h': // %h Hour (01..12) case 'I': // %I Hour (01..12) builder.appendClockhourOfHalfday(2); break; case 'i': // %i Minutes, numeric (00..59) builder.appendMinuteOfHour(2); break; case 'j': // %j Day of year (001..366) builder.appendDayOfYear(3); break; case 'k': // %k Hour (0..23) builder.appendHourOfDay(1); break; case 'l': // %l Hour (1..12) builder.appendClockhourOfHalfday(1); break; case 'M': // %M Month name (January..December) builder.appendMonthOfYearText(); break; case 'm': // %m Month, numeric (00..12) builder.appendMonthOfYear(2); break; case 'p': // %p AM or PM builder.appendHalfdayOfDayText(); break; case 'r': // %r Time, 12-hour (hh:mm:ss followed by AM or PM) builder.appendClockhourOfHalfday(2).appendLiteral(':').appendMinuteOfHour(2).appendLiteral(':') .appendSecondOfMinute(2).appendLiteral(' ').appendHalfdayOfDayText(); break; case 'S': // %S Seconds (00..59) case 's': // %s Seconds (00..59) builder.appendSecondOfMinute(2); break; case 'T': // %T Time, 24-hour (hh:mm:ss) builder.appendHourOfDay(2).appendLiteral(':').appendMinuteOfHour(2).appendLiteral(':') .appendSecondOfMinute(2); break; case 'v': // %v Week (01..53), where Monday is the first day of the week; used with %x builder.appendWeekOfWeekyear(2); break; case 'x': // %x Year for the week, where Monday is the first day of the week, numeric, four digits; used with %v builder.appendWeekyear(4, 4); break; case 'W': // %W Weekday name (Sunday..Saturday) builder.appendDayOfWeekText(); break; case 'Y': // %Y Year, numeric, four digits builder.appendYear(4, 4); break; case 'y': // %y Year, numeric (two digits) builder.appendTwoDigitYear(PIVOT_YEAR); break; case 'w': // %w Day of the week (0=Sunday..6=Saturday) case 'U': // %U Week (00..53), where Sunday is the first day of the week case 'u': // %u Week (00..53), where Monday is the first day of the week case 'V': // %V Week (01..53), where Sunday is the first day of the week; used with %X case 'X': // %X Year for the week where Sunday is the first day of the week, numeric, four digits; used with %V case 'D': // %D Day of the month with English suffix (0th, 1st, 2nd, 3rd, ) throw new PrestoException(INVALID_FUNCTION_ARGUMENT, String.format("%%%s not supported in date format string", character)); case '%': // %% A literal %? character builder.appendLiteral('%'); break; default: // %<x> The literal character represented by <x> builder.appendLiteral(character); break; }//from ww w . ja v a 2 s . c o m escaped = false; } else if (character == '%') { escaped = true; } else { builder.appendLiteral(character); } } try { return builder.toFormatter(); } catch (UnsupportedOperationException e) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, e); } }
From source file:io.smalldata.ohmageomh.surveys.domain.ISOW3CDateTimeFormat.java
License:Apache License
/** * Returns a formatter that combines a full date, two digit hour of the * day, two digit minute of the hour and a time zone. * //from w w w.j a v a 2 s.c o m * @return A formatter for the date, hour, minute, and time zone. */ public static DateTimeFormatter dateHourMinuteZone() { if (yearMonthDayHourMinuteZone == null) { DateTimeFormatterBuilder dateHourMinuteTimezone = new DateTimeFormatterBuilder(); dateHourMinuteTimezone.append(ISODateTimeFormat.dateHourMinute()); dateHourMinuteTimezone.append(DateTimeFormat.forPattern("ZZ")); yearMonthDayHourMinuteZone = dateHourMinuteTimezone.toFormatter().withOffsetParsed(); } return yearMonthDayHourMinuteZone; }
From source file:io.symcpe.hendrix.nifi.lmm.interceptor.LMMInterceptor.java
License:Apache License
@Override protected void init(ProcessorInitializationContext context) { List<PropertyDescriptor> properties = new ArrayList<>(); properties.add(TENANT_ID);/*from ww w . j a v a 2 s .co m*/ properties.add(TIMESTAMP); properties.add(API_KEY); this.properties = Collections.unmodifiableList(properties); Set<Relationship> relationships = new HashSet<>(); relationships.add(SUCCESS); relationships.add(FAILURE); this.relationships = Collections.unmodifiableSet(relationships); formatter = new DateTimeFormatterBuilder().append(null, formats).toFormatter(); }
From source file:mobi.daytoday.DayToDay.DateWrap.java
License:Apache License
/** * Add the number of days to the date and return the result * /*from w w w . j a va 2s .co m*/ * @param theDate * - date in DATE_FORMAT format * @param numDays * - number of days to add (may be negative for subtraction) * @return result of the addition in DATE_FORMAT format * @throws Exception * - if there is any error */ public static String addToDate(String theDate, int numDays) throws Exception { DateTime date = dtForm.parseDateTime(theDate); Duration days = standardDays(numDays); DateTime result = date.plus(days); DateTimeFormatter MonthDayYearFormat = new DateTimeFormatterBuilder().appendMonthOfYear(1) .appendLiteral('-').appendDayOfMonth(1).appendLiteral('-').appendYear(4, 4).toFormatter(); return MonthDayYearFormat.print(result); }
From source file:nat.pettipaw.com.pointchecker.DateTimeConverter.java
License:Open Source License
public DateTimeConverter() { if (formatter == null) formatter = new DateTimeFormatterBuilder().appendPattern("MM/dd/yy HH:mm:ss").toFormatter(); }