Skip to content

Commit

Permalink
Added OffsetTime conversion toString.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdereg committed Feb 3, 2024
1 parent 376bfb8 commit 6997c78
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ([email protected])
* <br>
* Copyright (c) Cedar Software LLC
* <br><br>
* 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
* <br><br>
* <a href="http://www.apache.org/licenses/LICENSE-2.0">License</a>
* <br><br>
* 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() {}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.cedarsoftware.util.convert;

import java.time.OffsetTime;
import java.time.format.DateTimeFormatter;

/**
* @author John DeRegnaucourt ([email protected])
* <br>
* Copyright (c) Cedar Software LLC
* <br><br>
* 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
* <br><br>
* <a href="http://www.apache.org/licenses/LICENSE-2.0">License</a>
* <br><br>
* 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);
}
}

0 comments on commit 6997c78

Please sign in to comment.