本文整理汇总了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);
}
}