List of usage examples for org.joda.time.format DateTimeFormatterBuilder DateTimeFormatterBuilder
public DateTimeFormatterBuilder()
From source file:com.facebook.presto.teradata.functions.dateformat.DateFormatParser.java
License:Apache License
public static DateTimeFormatter createDateTimeFormatter(String format) { DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder(); for (Token token : tokenize(format)) { switch (token.getType()) { case DateFormat.TEXT: builder.appendLiteral(token.getText()); break; case DateFormat.DD: builder.appendDayOfMonth(2); break; case DateFormat.HH24: builder.appendHourOfDay(2);/*from ww w. j a va 2s .co m*/ break; case DateFormat.HH: builder.appendHourOfHalfday(2); break; case DateFormat.MI: builder.appendMinuteOfHour(2); break; case DateFormat.MM: builder.appendMonthOfYear(2); break; case DateFormat.SS: builder.appendSecondOfMinute(2); break; case DateFormat.YY: builder.appendTwoDigitYear(2050); break; case DateFormat.YYYY: builder.appendYear(4, 4); break; case DateFormat.UNRECOGNIZED: default: throw new PrestoException(StandardErrorCode.INVALID_FUNCTION_ARGUMENT, String.format("Failed to tokenize string [%s] at offset [%d]", token.getText(), token.getCharPositionInLine())); } } try { return builder.toFormatter(); } catch (UnsupportedOperationException e) { throw new PrestoException(INVALID_FUNCTION_ARGUMENT, e); } }
From source file:com.forecast.io.v2.transfer.DataPoint.java
License:Apache License
/** (Added by Androidsx.) */ @Override//from w w w . j a v a 2s. co m public String toString() { final DateTimeFormatter debugDateTimeFormatter = new DateTimeFormatterBuilder().appendDayOfWeekShortText() .appendLiteral(", ").appendMonthOfYearShortText().appendLiteral(" ").appendDayOfMonth(2) .appendLiteral(" at ").appendHourOfDay(2).appendLiteral(":").appendMinuteOfHour(2) .appendLiteral(":").appendSecondOfMinute(2).toFormatter().withLocale(Locale.US); return "[" + debugDateTimeFormatter.print(getTime() * 1000) + "] " + "\"" + getIcon() + "\", " + "(temp: " + getTemperature() + ")"; }
From source file:com.fourmob.datetimepicker.date.DatePicker.java
License:Open Source License
private void updateDisplay() { if (this.mDayOfWeekView != null) { mSelectedMonthTextView.setText(new DateTimeFormatterBuilder().appendDayOfWeekShortText().toFormatter() .print(mCalendar).toUpperCase(Helpers.getLocale(getContext()))); }//from ww w .ja va 2s.c om mSelectedMonthTextView.setText(new DateTimeFormatterBuilder().appendMonthOfYearShortText().toFormatter() .print(mCalendar).toUpperCase(Helpers.getLocale(getContext()))); mSelectedDayTextView .setText(new DateTimeFormatterBuilder().appendDayOfMonth(0).toFormatter().print(mCalendar)); mYearView.setText(new DateTimeFormatterBuilder().appendYear(4, 4).toFormatter().print(mCalendar)); final long timeInMillis = this.mCalendar.toDateTimeAtStartOfDay().getMillis(); final String desc = DateUtils.formatDateTime(this.ctx, timeInMillis, 24); this.mMonthAndDayView.setContentDescription(desc); }
From source file:com.fourmob.datetimepicker.date.SimpleMonthView.java
License:Open Source License
private void drawMonthDayLabels(final Canvas canvas) { final int y = MONTH_HEADER_SIZE - MONTH_DAY_LABEL_TEXT_SIZE / 2; final int space = (this.mWidth - 2 * this.mPadding) / (2 * SimpleMonthView.mNumDays); for (int day = 0; day < SimpleMonthView.mNumDays; day++) { int dayOfWeek = (day + this.mWeekStart); if (dayOfWeek > DateTimeConstants.SUNDAY) { dayOfWeek -= DateTimeConstants.SUNDAY; }//from w w w . j a va 2s .co m final int x = space * (1 + day * 2) + this.mPadding; mDayLabelCalendar = mDayLabelCalendar.withDayOfWeek(dayOfWeek); canvas.drawText(new DateTimeFormatterBuilder().appendDayOfWeekShortText().toFormatter() .print(mDayLabelCalendar), x, y, this.mMonthDayLabelPaint); } }
From source file:com.github.fge.jsonschema.format.draftv3.DateAttribute.java
License:LGPL
@Override protected DateTimeFormatter getFormatter() { DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder(); builder = builder.appendFixedDecimal(year(), 4).appendLiteral('-').appendFixedDecimal(monthOfYear(), 2) .appendLiteral('-').appendFixedDecimal(dayOfMonth(), 2); return builder.toFormatter(); }
From source file:com.github.fge.jsonschema.format.draftv3.TimeAttribute.java
License:LGPL
@Override protected DateTimeFormatter getFormatter() { DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder(); builder = builder.appendFixedDecimal(hourOfDay(), 2).appendLiteral(':') .appendFixedDecimal(minuteOfHour(), 2).appendLiteral(':').appendFixedDecimal(secondOfMinute(), 2); return builder.toFormatter(); }
From source file:com.github.seratch.yahooapis.setsuden.response.ElectricPowerForecast.java
License:Apache License
public static DateTimeFormatter getDateFormat() { DateTimeFormatter inputFormatter = new DateTimeFormatterBuilder().appendYear(4, 4).appendLiteral("-") .appendMonthOfYear(2).appendLiteral("-").appendDayOfMonth(2).toFormatter(); return inputFormatter; }
From source file:com.github.seratch.yahooapis.setsuden.response.ElectricPowerForecast.java
License:Apache License
public static DateTimeFormatter getTimeFormat() { DateTimeFormatter inputFormatter = new DateTimeFormatterBuilder().appendYear(4, 4).appendLiteral("-") .appendMonthOfYear(2).appendLiteral("-").appendDayOfMonth(2).appendLiteral("T").appendHourOfDay(2) .appendLiteral(":").appendMinuteOfDay(2).appendLiteral(":").appendSecondOfDay(2) .appendLiteral("+09:00").toFormatter(); return inputFormatter; }
From source file:com.github.seratch.yahooapis.setsuden.response.ElectricPowerUsage.java
License:Apache License
public DateTimeFormatter getDateFormat() { DateTimeFormatter inputFormatter = new DateTimeFormatterBuilder().appendYear(4, 4).appendLiteral("-") .appendMonthOfYear(2).appendLiteral("-").appendDayOfMonth(2).toFormatter(); return inputFormatter; }
From source file:com.hmsinc.epicenter.velocity.DateTimeFormatTool.java
License:Open Source License
/** * Checks a string to see if it matches one of the standard DateTimeFormat * style patterns: full, long, medium, short, or default. */// w w w . j a va2 s. c om private static DateTimeFormatter getDateTimeStyle(String dateStyle, String timeStyle, Locale locale, DateTimeZone zone) { final DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder(); final DateTimeFormatter date = getDateStyle(dateStyle, locale, zone); if (date != null) { builder.append(date); } final DateTimeFormatter time = getTimeStyle(timeStyle, locale, zone); if (date != null && time != null) { builder.append(DateTimeFormat.forPattern(" ")); } if (time != null) { builder.append(time); } return builder.toFormatter(); }