java.time.OffsetTime#format ( )源码实例Demo

下面列出了java.time.OffsetTime#format ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
public void serialize(OffsetTime time, JsonGenerator g, SerializerProvider provider) throws IOException
{
    if (useTimestamp(provider)) {
        g.writeStartArray();
        _serializeAsArrayContents(time, g, provider);
        g.writeEndArray();
    } else {
        String str = (_formatter == null) ? time.toString() : time.format(_formatter);
        g.writeString(str);
    }
}
 
@Override
public void serializeWithType(OffsetTime value, JsonGenerator g, SerializerProvider ctxt,
        TypeSerializer typeSer) throws IOException
{
    WritableTypeId typeIdDef = typeSer.writeTypePrefix(g, ctxt,
            typeSer.typeId(value, serializationShape(ctxt)));
    // need to write out to avoid double-writing array markers
    if (typeIdDef.valueShape == JsonToken.START_ARRAY) {
        _serializeAsArrayContents(value, g, ctxt);
    } else {
        String str = (_formatter == null) ? value.toString() : value.format(_formatter);
        g.writeString(str);
    }
    typeSer.writeTypeSuffix(g, ctxt, typeIdDef);
}
 
源代码3 项目: groovy   文件: DateTimeExtensions.java
/**
 * Formats this time with the provided {@link java.time.format.DateTimeFormatter} pattern.
 *
 * @param self    an OffsetTime
 * @param pattern the formatting pattern
 * @return a formatted String
 * @see java.time.format.DateTimeFormatter
 * @since 2.5.0
 */
public static String format(final OffsetTime self, String pattern) {
    return self.format(DateTimeFormatter.ofPattern(pattern));
}
 
源代码4 项目: groovy   文件: DateTimeExtensions.java
/**
 * Formats this time in the provided, localized {@link java.time.format.FormatStyle}.
 *
 * @param self      an OffsetTime
 * @param timeStyle the FormatStyle
 * @return a formatted String
 * @see java.time.format.DateTimeFormatter
 * @since 2.5.0
 */
public static String format(final OffsetTime self, FormatStyle timeStyle) {
    return self.format(DateTimeFormatter.ofLocalizedTime(timeStyle));
}
 
源代码5 项目: groovy   文件: DateTimeExtensions.java
/**
 * Formats this time with the {@link java.time.format.DateTimeFormatter#ISO_OFFSET_TIME} formatter.
 *
 * @param self an OffsetTime
 * @return a formatted String
 * @see java.time.format.DateTimeFormatter
 * @since 2.5.0
 */
public static String getTimeString(final OffsetTime self) {
    return self.format(DateTimeFormatter.ISO_OFFSET_TIME);
}