diff --git a/src/main/java/com/cedarsoftware/util/convert/Converter.java b/src/main/java/com/cedarsoftware/util/convert/Converter.java index e6ed6a93..3be35b19 100644 --- a/src/main/java/com/cedarsoftware/util/convert/Converter.java +++ b/src/main/java/com/cedarsoftware/util/convert/Converter.java @@ -640,6 +640,7 @@ private static void buildFactoryConversions() { DEFAULT_FACTORY.put(pair(Instant.class, String.class), StringConversions::toString); DEFAULT_FACTORY.put(pair(LocalTime.class, String.class), StringConversions::toString); DEFAULT_FACTORY.put(pair(MonthDay.class, String.class), StringConversions::toString); + DEFAULT_FACTORY.put(pair(OffsetTime.class, String.class), OffsetTimeConversions::toString); DEFAULT_FACTORY.put(pair(OffsetDateTime.class, String.class), OffsetDateTimeConversions::toString); DEFAULT_FACTORY.put(pair(Year.class, String.class), YearConversions::toString); diff --git a/src/main/java/com/cedarsoftware/util/convert/OffsetDateTimeConversions.java b/src/main/java/com/cedarsoftware/util/convert/OffsetDateTimeConversions.java index 9146f691..e3b68cec 100644 --- a/src/main/java/com/cedarsoftware/util/convert/OffsetDateTimeConversions.java +++ b/src/main/java/com/cedarsoftware/util/convert/OffsetDateTimeConversions.java @@ -9,14 +9,28 @@ import java.time.LocalTime; import java.time.OffsetDateTime; import java.time.OffsetTime; -import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.Calendar; import java.util.Date; -import java.util.GregorianCalendar; import java.util.concurrent.atomic.AtomicLong; -import java.util.stream.Stream; +/** + * @author Kenny Partlow (kpartlow@gmail.com) + *
+ * Copyright (c) Cedar Software LLC + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * License + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ public class OffsetDateTimeConversions { private OffsetDateTimeConversions() {} diff --git a/src/main/java/com/cedarsoftware/util/convert/OffsetTimeConversions.java b/src/main/java/com/cedarsoftware/util/convert/OffsetTimeConversions.java new file mode 100644 index 00000000..5f1ad0e6 --- /dev/null +++ b/src/main/java/com/cedarsoftware/util/convert/OffsetTimeConversions.java @@ -0,0 +1,30 @@ +package com.cedarsoftware.util.convert; + +import java.time.OffsetTime; +import java.time.format.DateTimeFormatter; + +/** + * @author John DeRegnaucourt (jdereg@gmail.com) + *
+ * Copyright (c) Cedar Software LLC + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * License + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +public class OffsetTimeConversions { + private OffsetTimeConversions() {} + + static String toString(Object from, Converter converter, ConverterOptions options) { + OffsetTime offsetTime = (OffsetTime) from; + return offsetTime.format(DateTimeFormatter.ISO_OFFSET_TIME); + } +}