Skip to content

Commit

Permalink
Don't apply timezone to dates even if provided
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed May 29, 2021
1 parent c2cb256 commit b463a3a
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -135,7 +135,7 @@ public DateProperty(final String name, CalendarDateFormat parseFormat, Value def
public T getDate() {
if (date != null) {
Optional<TzId> tzId = getParameters().getFirst(Parameter.TZID);
if (tzId.isPresent()) {
if (tzId.isPresent() && shouldApplyTimezone()) {
return (T) date.toLocalTime(tzId.get().toZoneId(timeZoneRegistry));
} else {
return date.getTemporal();
Expand Down Expand Up @@ -199,7 +199,7 @@ public void setValue(final String value) throws DateTimeParseException {
@Override
public String getValue() {
Optional<TzId> tzId = getParameters().getFirst(Parameter.TZID);
if (tzId.isPresent()) {
if (tzId.isPresent() && shouldApplyTimezone()) {
return date.toString(tzId.get().toZoneId(timeZoneRegistry));
} else {
return Strings.valueOf(date);
Expand All @@ -210,6 +210,11 @@ public void setTimeZoneRegistry(TimeZoneRegistry timeZoneRegistry) {
this.timeZoneRegistry = timeZoneRegistry;
}

private boolean shouldApplyTimezone() {
Optional<Value> value = getParameters().getFirst(VALUE);
return !Optional.of(Value.DATE).equals(value);
}

/**
* {@inheritDoc}
*/
Expand Down

0 comments on commit b463a3a

Please sign in to comment.