本文整理匯總了Java中org.joda.time.format.DateTimeFormatterBuilder.appendMonthOfYear方法的典型用法代碼示例。如果您正苦於以下問題:Java DateTimeFormatterBuilder.appendMonthOfYear方法的具體用法?Java DateTimeFormatterBuilder.appendMonthOfYear怎麽用?Java DateTimeFormatterBuilder.appendMonthOfYear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.joda.time.format.DateTimeFormatterBuilder
的用法示例。
在下文中一共展示了DateTimeFormatterBuilder.appendMonthOfYear方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createDateTimeFormatter
import org.joda.time.format.DateTimeFormatterBuilder; //導入方法依賴的package包/類
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);
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);
}
}