本文整理匯總了Java中org.joda.time.format.DateTimeFormatterBuilder.appendSecondOfMinute方法的典型用法代碼示例。如果您正苦於以下問題:Java DateTimeFormatterBuilder.appendSecondOfMinute方法的具體用法?Java DateTimeFormatterBuilder.appendSecondOfMinute怎麽用?Java DateTimeFormatterBuilder.appendSecondOfMinute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.joda.time.format.DateTimeFormatterBuilder
的用法示例。
在下文中一共展示了DateTimeFormatterBuilder.appendSecondOfMinute方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: appendTimeFormats
import org.joda.time.format.DateTimeFormatterBuilder; //導入方法依賴的package包/類
protected boolean appendTimeFormats(DateTimeFormatterBuilder builder, int flags) {
boolean alwaysPad = (flags & SUTime.FORMAT_PAD_UNKNOWN) != 0;
boolean hasTime = hasTime();
DateTimeFieldType sdft = JodaTimeUtils.getMostSpecific(base);
if (hasTime) {
builder.appendLiteral("T");
if (JodaTimeUtils.hasField(base, DateTimeFieldType.hourOfDay())) {
builder.appendHourOfDay(2);
} else if (JodaTimeUtils.hasField(base, DateTimeFieldType.clockhourOfDay())) {
builder.appendClockhourOfDay(2);
} else {
builder.appendLiteral(SUTime.PAD_FIELD_UNKNOWN2);
}
if (JodaTimeUtils.hasField(base, DateTimeFieldType.minuteOfHour())) {
builder.appendLiteral(":");
builder.appendMinuteOfHour(2);
} else if (alwaysPad || JodaTimeUtils.isMoreGeneral(DateTimeFieldType.minuteOfHour(), sdft, base.getChronology())) {
builder.appendLiteral(":");
builder.appendLiteral(SUTime.PAD_FIELD_UNKNOWN2);
}
if (JodaTimeUtils.hasField(base, DateTimeFieldType.secondOfMinute())) {
builder.appendLiteral(":");
builder.appendSecondOfMinute(2);
} else if (alwaysPad || JodaTimeUtils.isMoreGeneral(DateTimeFieldType.secondOfMinute(), sdft, base.getChronology())) {
builder.appendLiteral(":");
builder.appendLiteral(SUTime.PAD_FIELD_UNKNOWN2);
}
if (JodaTimeUtils.hasField(base, DateTimeFieldType.millisOfSecond())) {
builder.appendLiteral(".");
builder.appendMillisOfSecond(3);
}
// builder.append(isoTimeFormatter);
}
return hasTime;
}
示例2: 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);
}
}