Skip to content

Package: ZonedDateTimeSerializer

ZonedDateTimeSerializer

nameinstructionbranchcomplexitylinemethod
ZonedDateTimeSerializer(TypeSerializerBuilder)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
formatDefault(ZonedDateTime, Locale)
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
toInstant(ZonedDateTime)
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 2016, 2022 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0 which is available at
6: * http://www.eclipse.org/legal/epl-2.0,
7: * or the Eclipse Distribution License v. 1.0 which is available at
8: * http://www.eclipse.org/org/documents/edl-v10.php.
9: *
10: * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
11: */
12:
13: package org.eclipse.yasson.internal.serializer.types;
14:
15: import java.time.Instant;
16: import java.time.ZonedDateTime;
17: import java.time.format.DateTimeFormatter;
18: import java.util.Locale;
19:
20: /**
21: * Serializer of the {@link ZonedDateTime} type.
22: */
23: class ZonedDateTimeSerializer extends AbstractDateSerializer<ZonedDateTime> {
24:
25: ZonedDateTimeSerializer(TypeSerializerBuilder serializerBuilder) {
26: super(serializerBuilder);
27: }
28:
29: @Override
30: protected Instant toInstant(ZonedDateTime value) {
31: return value.toInstant();
32: }
33:
34: @Override
35: protected String formatDefault(ZonedDateTime value, Locale locale) {
36: return DateTimeFormatter.ISO_ZONED_DATE_TIME.withLocale(locale).format(value);
37: }
38: }