Skip to content

Commit

Permalink
Updated FIX for rico-projects#43
Browse files Browse the repository at this point in the history
  • Loading branch information
Jörg Hälker committed Jan 29, 2019
1 parent b3fe164 commit 97f040a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright 2018-2019 Karakun AG.
* Copyright 2015-2016 Canoo Engineering AG.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -26,14 +27,15 @@

/**
* Created by hendrikebbers on 25.10.16.
* Adopted by Jörg Hälker on 29.01.18.
*/
public class InstantConverterFactory extends AbstractConverterFactory {

@SuppressWarnings("rawtypes")
private final static Converter CONVERTER = new InstantConverter();

@Override
public boolean supportsType(Class<?> cls) {
public boolean supportsType(final Class<?> cls) {
return Instant.class.isAssignableFrom(cls);
}

Expand All @@ -48,14 +50,14 @@ public int getTypeIdentifier() {
}

@Override
public Converter getConverterForType(Class<?> cls) {
public Converter getConverterForType(final Class<?> cls) {
return CONVERTER;
}

private static class InstantConverter extends AbstractStringConverter<Instant> {

@Override
public Instant convertFromRemoting(String value) throws ValueConverterException {
public Instant convertFromRemoting(final String value) throws ValueConverterException {
if (value == null) {
return null;
}
Expand All @@ -67,7 +69,7 @@ public Instant convertFromRemoting(String value) throws ValueConverterException
}

@Override
public String convertToRemoting(Instant value) throws ValueConverterException {
public String convertToRemoting(final Instant value) throws ValueConverterException {
if (value == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,16 @@ public int getTypeIdentifier() {
private static class LocalDateConverter
extends AbstractDateConverter<LocalDate> {

private static final String UTC = "UTC";

@Override
public LocalDate convertFromRemoting(final String value)
throws ValueConverterException {
if (value == null) {
return null;
}
try {
final Calendar result = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
final Calendar result = Calendar.getInstance(TimeZone.getTimeZone(UTC));
result.setTime(getDateFormat().parse(value));
return result.toInstant().atZone(ZoneOffset.UTC).toLocalDate();
} catch (final Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright 2018-2019 Karakun AG.
* Copyright 2015-2016 Canoo Engineering AG.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -26,14 +27,15 @@

/**
* Created by hendrikebbers on 25.10.16.
* Adopted by Jörg Hälker on 29.01.18.
*/
public class LocalTimeConverterFactory extends AbstractConverterFactory {

@SuppressWarnings("rawtypes")
private final static Converter CONVERTER = new LocalTimeConverter();

@Override
public boolean supportsType(Class<?> cls) {
public boolean supportsType(final Class<?> cls) {
return LocalTime.class.isAssignableFrom(cls);
}

Expand All @@ -48,14 +50,14 @@ public int getTypeIdentifier() {
}

@Override
public Converter getConverterForType(Class<?> cls) {
public Converter getConverterForType(final Class<?> cls) {
return CONVERTER;
}

private static class LocalTimeConverter extends AbstractStringConverter<LocalTime> {

@Override
public LocalTime convertFromRemoting(String value) throws ValueConverterException {
public LocalTime convertFromRemoting(final String value) throws ValueConverterException {
if (value == null) {
return null;
}
Expand All @@ -67,7 +69,7 @@ public LocalTime convertFromRemoting(String value) throws ValueConverterExceptio
}

@Override
public String convertToRemoting(LocalTime value) throws ValueConverterException {
public String convertToRemoting(final LocalTime value) throws ValueConverterException {
if (value == null) {
return null;
}
Expand Down

0 comments on commit 97f040a

Please sign in to comment.