Java Code Examples for java.time.OffsetTime#format()
The following examples show how to use
java.time.OffsetTime#format() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OffsetTimeSerializer.java From jackson-modules-java8 with Apache License 2.0 | 5 votes |
@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); } }
Example 2
Source File: OffsetTimeSerializer.java From jackson-modules-java8 with Apache License 2.0 | 5 votes |
@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); }
Example 3
Source File: DateTimeExtensions.java From groovy with Apache License 2.0 | 2 votes |
/** * 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)); }
Example 4
Source File: DateTimeExtensions.java From groovy with Apache License 2.0 | 2 votes |
/** * 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)); }
Example 5
Source File: DateTimeExtensions.java From groovy with Apache License 2.0 | 2 votes |
/** * 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); }