From 083c38693b4640faea810e8f3db4e97ff4633888 Mon Sep 17 00:00:00 2001 From: Ben Fortuna Date: Tue, 30 Jul 2019 00:18:21 +1000 Subject: [PATCH] Code clean up --- .../java/net/fortuna/ical4j/model/CalendarDateFormat.java | 2 +- src/main/java/net/fortuna/ical4j/model/Property.java | 8 ++++---- .../java/net/fortuna/ical4j/model/property/DtStamp.java | 7 ++----- .../java/net/fortuna/ical4j/util/FixedUidGenerator.java | 3 +-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/main/java/net/fortuna/ical4j/model/CalendarDateFormat.java b/src/main/java/net/fortuna/ical4j/model/CalendarDateFormat.java index 401e42561..fcfba6496 100644 --- a/src/main/java/net/fortuna/ical4j/model/CalendarDateFormat.java +++ b/src/main/java/net/fortuna/ical4j/model/CalendarDateFormat.java @@ -194,7 +194,7 @@ private DateTimeFormatter getFormatter() { synchronized (pattern) { if (formatter == null) { formatter = DateTimeFormatter.ofPattern(pattern); - if (pattern.endsWith("Z")) { + if (pattern.endsWith("'Z'")) { formatter = formatter.withZone(ZoneOffset.UTC); } } diff --git a/src/main/java/net/fortuna/ical4j/model/Property.java b/src/main/java/net/fortuna/ical4j/model/Property.java index 89fa9fc57..0cd5c3ed1 100644 --- a/src/main/java/net/fortuna/ical4j/model/Property.java +++ b/src/main/java/net/fortuna/ical4j/model/Property.java @@ -361,7 +361,7 @@ public abstract class Property extends Content { private final ParameterList parameters; - private final PropertyFactory factory; + private final PropertyFactory factory; /** * Constructor. @@ -387,7 +387,7 @@ protected Property(final String aName, PropertyFactory factory) { * @param aList a list of initial parameters * @param factory the factory used to create the property instance */ - protected Property(final String aName, final ParameterList aList, PropertyFactory factory) { + protected Property(final String aName, final ParameterList aList, PropertyFactory factory) { this.name = aName; this.parameters = aList; this.factory = factory; @@ -521,12 +521,12 @@ public int hashCode() { * @throws URISyntaxException where the property contains an invalid URI value * @throws ParseException where the property contains an invalid date value */ - public Property copy() throws IOException, URISyntaxException, ParseException { + public T copy() throws IOException, URISyntaxException, ParseException { if (factory == null) { throw new UnsupportedOperationException("No factory specified"); } // Deep copy parameter list.. final ParameterList params = new ParameterList(getParameters(), false); - return factory.createProperty(params, getValue()); + return (T) factory.createProperty(params, getValue()); } } diff --git a/src/main/java/net/fortuna/ical4j/model/property/DtStamp.java b/src/main/java/net/fortuna/ical4j/model/property/DtStamp.java index d150f633a..644dc3616 100644 --- a/src/main/java/net/fortuna/ical4j/model/property/DtStamp.java +++ b/src/main/java/net/fortuna/ical4j/model/property/DtStamp.java @@ -100,19 +100,16 @@ public DtStamp() { /** * @param aValue a string representation of a DTSTAMP value - * @throws ParseException if the specified value is not a valid representation */ - public DtStamp(final String aValue) throws ParseException { + public DtStamp(final String aValue) { this(new ParameterList(), aValue); } /** * @param aList a list of parameters for this component * @param aValue a value string for this component - * @throws ParseException where the specified value string is not a valid date-time/date representation */ - public DtStamp(final ParameterList aList, final String aValue) - throws ParseException { + public DtStamp(final ParameterList aList, final String aValue) { super(DTSTAMP, aList, new Factory()); setValue(aValue); } diff --git a/src/main/java/net/fortuna/ical4j/util/FixedUidGenerator.java b/src/main/java/net/fortuna/ical4j/util/FixedUidGenerator.java index 6d256a61f..c32ee54b8 100644 --- a/src/main/java/net/fortuna/ical4j/util/FixedUidGenerator.java +++ b/src/main/java/net/fortuna/ical4j/util/FixedUidGenerator.java @@ -102,7 +102,6 @@ private static TemporalAdapter uniqueTimestamp() { } lastMillis = currentMillis; } - final TemporalAdapter timestamp = new TemporalAdapter<>(Instant.ofEpochMilli(currentMillis), TemporalAdapter.FormatType.DateTimeUtc); - return timestamp; + return new TemporalAdapter<>(Instant.ofEpochMilli(currentMillis)); } }