diff --git a/src/main/java/com/ethlo/time/FastInternetDateTimeUtil.java b/src/main/java/com/ethlo/time/FastInternetDateTimeUtil.java index 4066a9a..110583a 100644 --- a/src/main/java/com/ethlo/time/FastInternetDateTimeUtil.java +++ b/src/main/java/com/ethlo/time/FastInternetDateTimeUtil.java @@ -35,8 +35,6 @@ public class FastInternetDateTimeUtil extends AbstractRfc3339 implements W3cDateTimeUtil { public static final int LEAP_SECOND_SECONDS = 60; - private final StdJdkInternetDateTimeUtil delegate = new StdJdkInternetDateTimeUtil(); - private static final char PLUS = '+'; private static final char MINUS = '-'; private static final char DATE_SEPARATOR = '-'; @@ -48,6 +46,7 @@ public class FastInternetDateTimeUtil extends AbstractRfc3339 implements W3cDate private static final char ZULU_UPPER = 'Z'; private static final char ZULU_LOWER = 'z'; private static final int[] widths = new int[]{100_000_000, 10_000_000, 1_000_000, 100_000, 10_000, 1_000, 100, 10, 1}; + private final StdJdkInternetDateTimeUtil delegate = new StdJdkInternetDateTimeUtil(); @Override public OffsetDateTime parseDateTime(String s) @@ -414,7 +413,7 @@ else if (remaining == 0) && utcMinute == 59) { // Consider it a leap second - return OffsetDateTime.of(year, month, day, hour, minute, 59, fractions, offset).plusSeconds(1); + throw new LeapSecondException(OffsetDateTime.of(year, month, day, hour, minute, 59, fractions, offset).plusSeconds(1), second); } } return OffsetDateTime.of(year, month, day, hour, minute, second, fractions, offset); diff --git a/src/main/java/com/ethlo/time/LeapSecondException.java b/src/main/java/com/ethlo/time/LeapSecondException.java new file mode 100644 index 0000000..02daed4 --- /dev/null +++ b/src/main/java/com/ethlo/time/LeapSecondException.java @@ -0,0 +1,5 @@ +package com.ethlo.time; + +public class LeapSecondException extends Throwable +{ +} diff --git a/src/test/java/com/ethlo/time/FastCorrectnessTest.java b/src/test/java/com/ethlo/time/FastCorrectnessTest.java index e36e69f..b0c3dfc 100644 --- a/src/test/java/com/ethlo/time/FastCorrectnessTest.java +++ b/src/test/java/com/ethlo/time/FastCorrectnessTest.java @@ -9,9 +9,9 @@ * 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 - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * 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.