diff --git a/src/main/java/com/ethlo/time/DateTime.java b/src/main/java/com/ethlo/time/DateTime.java index 72dc7d0..c28431f 100644 --- a/src/main/java/com/ethlo/time/DateTime.java +++ b/src/main/java/com/ethlo/time/DateTime.java @@ -20,10 +20,10 @@ * #L% */ +import static com.ethlo.time.internal.fixed.ITUFormatter.finish; import static com.ethlo.time.internal.fixed.ITUParser.DATE_SEPARATOR; import static com.ethlo.time.internal.fixed.ITUParser.SEPARATOR_UPPER; import static com.ethlo.time.internal.fixed.ITUParser.TIME_SEPARATOR; -import static com.ethlo.time.internal.fixed.ITUFormatter.finish; import static com.ethlo.time.internal.util.LeapSecondHandler.LEAP_SECOND_SECONDS; import java.time.DateTimeException; diff --git a/src/main/java/com/ethlo/time/ITU.java b/src/main/java/com/ethlo/time/ITU.java index a2545b4..4d51227 100644 --- a/src/main/java/com/ethlo/time/ITU.java +++ b/src/main/java/com/ethlo/time/ITU.java @@ -71,7 +71,8 @@ public static DateTime parseLenient(String text) /** * Allows parsing leniently with {@link ParseConfig to control some aspects of the parsing} - * @param text The text to parse + * + * @param text The text to parse * @param parseConfig The configuration to use for parsing * @return The date-time parsed */ @@ -81,10 +82,9 @@ public static DateTime parseLenient(String text, ParseConfig parseConfig) } /** - * - * @param text The text to parse + * @param text The text to parse * @param parseConfig The configuration to use for parsing - * @param position The position to start parsing from. The index (and the errorIndex, if an error occurs) is updated after the parsing process has completed + * @param position The position to start parsing from. The index (and the errorIndex, if an error occurs) is updated after the parsing process has completed * @return The date-time parsed */ public static DateTime parseLenient(String text, ParseConfig parseConfig, ParsePosition position) diff --git a/src/main/java/com/ethlo/time/ParseConfig.java b/src/main/java/com/ethlo/time/ParseConfig.java index 1d4ef8d..a038ee2 100644 --- a/src/main/java/com/ethlo/time/ParseConfig.java +++ b/src/main/java/com/ethlo/time/ParseConfig.java @@ -20,13 +20,11 @@ * #L% */ -import static com.ethlo.time.internal.fixed.ITUParser.SEPARATOR_LOWER; -import static com.ethlo.time.internal.fixed.ITUParser.SEPARATOR_SPACE; -import static com.ethlo.time.internal.fixed.ITUParser.SEPARATOR_UPPER; - import java.util.Arrays; import java.util.Optional; +import static com.ethlo.time.internal.fixed.ITUParser.*; + public class ParseConfig { private static final char[] DEFAULT_DATE_TIME_SEPARATORS = new char[]{SEPARATOR_UPPER, SEPARATOR_LOWER, SEPARATOR_SPACE}; diff --git a/src/main/java/com/ethlo/time/internal/fixed/ITUFormatter.java b/src/main/java/com/ethlo/time/internal/fixed/ITUFormatter.java index 2e10ee1..1efe741 100644 --- a/src/main/java/com/ethlo/time/internal/fixed/ITUFormatter.java +++ b/src/main/java/com/ethlo/time/internal/fixed/ITUFormatter.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. diff --git a/src/main/java/com/ethlo/time/internal/token/TimeZoneOffsetToken.java b/src/main/java/com/ethlo/time/internal/token/ZoneOffsetToken.java similarity index 97% rename from src/main/java/com/ethlo/time/internal/token/TimeZoneOffsetToken.java rename to src/main/java/com/ethlo/time/internal/token/ZoneOffsetToken.java index 76a0cc3..a253872 100644 --- a/src/main/java/com/ethlo/time/internal/token/TimeZoneOffsetToken.java +++ b/src/main/java/com/ethlo/time/internal/token/ZoneOffsetToken.java @@ -33,7 +33,7 @@ import com.ethlo.time.Field; import com.ethlo.time.token.DateTimeToken; -public class TimeZoneOffsetToken implements DateTimeToken +public class ZoneOffsetToken implements DateTimeToken { @Override public int read(final String text, final ParsePosition parsePosition) diff --git a/src/main/java/com/ethlo/time/internal/util/ArrayUtils.java b/src/main/java/com/ethlo/time/internal/util/ArrayUtils.java index e478395..e2ae22d 100644 --- a/src/main/java/com/ethlo/time/internal/util/ArrayUtils.java +++ b/src/main/java/com/ethlo/time/internal/util/ArrayUtils.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. diff --git a/src/main/java/com/ethlo/time/token/DateTimeToken.java b/src/main/java/com/ethlo/time/token/DateTimeToken.java index 94c97b8..dc7b561 100644 --- a/src/main/java/com/ethlo/time/token/DateTimeToken.java +++ b/src/main/java/com/ethlo/time/token/DateTimeToken.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. diff --git a/src/main/java/com/ethlo/time/token/DateTimeTokens.java b/src/main/java/com/ethlo/time/token/DateTimeTokens.java index 9d3a52e..61ba826 100644 --- a/src/main/java/com/ethlo/time/token/DateTimeTokens.java +++ b/src/main/java/com/ethlo/time/token/DateTimeTokens.java @@ -25,7 +25,7 @@ import com.ethlo.time.internal.token.FractionsToken; import com.ethlo.time.internal.token.SeparatorToken; import com.ethlo.time.internal.token.SeparatorsToken; -import com.ethlo.time.internal.token.TimeZoneOffsetToken; +import com.ethlo.time.internal.token.ZoneOffsetToken; public class DateTimeTokens { @@ -55,6 +55,6 @@ public static DateTimeToken fractions() public static DateTimeToken zoneOffset() { - return new TimeZoneOffsetToken(); + return new ZoneOffsetToken(); } } diff --git a/src/test/java/com/ethlo/time/ParsePositionTest.java b/src/test/java/com/ethlo/time/ParsePositionTest.java index 8e34738..22f0f03 100644 --- a/src/test/java/com/ethlo/time/ParsePositionTest.java +++ b/src/test/java/com/ethlo/time/ParsePositionTest.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. diff --git a/src/test/java/com/ethlo/time/token/ConfigurableDateTimeParserTest.java b/src/test/java/com/ethlo/time/token/ConfigurableDateTimeParserTest.java index 61a0365..3cf3e4c 100644 --- a/src/test/java/com/ethlo/time/token/ConfigurableDateTimeParserTest.java +++ b/src/test/java/com/ethlo/time/token/ConfigurableDateTimeParserTest.java @@ -41,7 +41,7 @@ import com.ethlo.time.DateTime; import com.ethlo.time.ITU; import com.ethlo.time.internal.token.FractionsToken; -import com.ethlo.time.internal.token.TimeZoneOffsetToken; +import com.ethlo.time.internal.token.ZoneOffsetToken; public class ConfigurableDateTimeParserTest { @@ -168,21 +168,21 @@ void reachEndOfFractions() void readTimeZoneZuluUpper() { final ParsePosition pos = new ParsePosition(0); - assertThat(new TimeZoneOffsetToken().read("Z", pos)).isEqualTo(0); + assertThat(new ZoneOffsetToken().read("Z", pos)).isEqualTo(0); } @Test void readTimeZoneZuluLower() { final ParsePosition pos = new ParsePosition(0); - assertThat(new TimeZoneOffsetToken().read("z", pos)).isEqualTo(0); + assertThat(new ZoneOffsetToken().read("z", pos)).isEqualTo(0); } @Test void readTimeZoneUnexpectedChar() { final ParsePosition pos = new ParsePosition(0); - final DateTimeParseException exc = assertThrows(DateTimeParseException.class, () -> new TimeZoneOffsetToken().read("X", pos)); + final DateTimeParseException exc = assertThrows(DateTimeParseException.class, () -> new ZoneOffsetToken().read("X", pos)); assertThat(exc).hasMessage("Expected character [Z, z, +, -] at position 1, found X: X"); } @@ -190,7 +190,7 @@ void readTimeZoneUnexpectedChar() void readTimeZoneTooShort() { final ParsePosition pos = new ParsePosition(0); - final DateTimeParseException exc = assertThrows(DateTimeParseException.class, () -> new TimeZoneOffsetToken().read("-06:0", pos)); + final DateTimeParseException exc = assertThrows(DateTimeParseException.class, () -> new ZoneOffsetToken().read("-06:0", pos)); assertThat(exc).hasMessage("Invalid timezone offset: -06:0"); } @@ -198,7 +198,7 @@ void readTimeZoneTooShort() void readTimeZoneNegative() { final ParsePosition pos = new ParsePosition(0); - final int secs = new TimeZoneOffsetToken().read("-06:30", pos); + final int secs = new ZoneOffsetToken().read("-06:30", pos); assertThat(secs).isEqualTo(-23400); } diff --git a/src/test/java/com/ethlo/time/token/DateTimeParsers.java b/src/test/java/com/ethlo/time/token/DateTimeParsers.java index fde8acb..976ab63 100644 --- a/src/test/java/com/ethlo/time/token/DateTimeParsers.java +++ b/src/test/java/com/ethlo/time/token/DateTimeParsers.java @@ -39,12 +39,6 @@ public class DateTimeParsers separators('-'), digits(DAY, 2) ); - - public static DateTimeParser of(DateTimeToken... tokens) - { - return ConfigurableDateTimeParser.of(tokens); - } - private static final DateTimeParser LOCAL_TIME = of( digits(HOUR, 2), separators(':'), @@ -54,6 +48,11 @@ public static DateTimeParser of(DateTimeToken... tokens) fractions() ); + public static DateTimeParser of(DateTimeToken... tokens) + { + return ConfigurableDateTimeParser.of(tokens); + } + public static DateTimeParser localDate() { return DATE;