Skip to content

Commit

Permalink
Code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Jul 29, 2019
1 parent e6b2b7d commit 083c386
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
Expand Up @@ -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);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/fortuna/ical4j/model/Property.java
Expand Up @@ -361,7 +361,7 @@ public abstract class Property extends Content {

private final ParameterList parameters;

private final PropertyFactory factory;
private final PropertyFactory<? extends Property> factory;

/**
* Constructor.
Expand All @@ -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<? extends Property> factory) {
this.name = aName;
this.parameters = aList;
this.factory = factory;
Expand Down Expand Up @@ -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 extends Property> 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());
}
}
7 changes: 2 additions & 5 deletions src/main/java/net/fortuna/ical4j/model/property/DtStamp.java
Expand Up @@ -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);
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/net/fortuna/ical4j/util/FixedUidGenerator.java
Expand Up @@ -102,7 +102,6 @@ private static TemporalAdapter<Instant> uniqueTimestamp() {
}
lastMillis = currentMillis;
}
final TemporalAdapter<Instant> timestamp = new TemporalAdapter<>(Instant.ofEpochMilli(currentMillis), TemporalAdapter.FormatType.DateTimeUtc);
return timestamp;
return new TemporalAdapter<>(Instant.ofEpochMilli(currentMillis));
}
}

0 comments on commit 083c386

Please sign in to comment.