Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/main/java/org/opentripplanner/ojp/time/XmlDateTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.Objects;

/**
Expand All @@ -23,6 +24,13 @@ public XmlDateTime(LocalDateTime localDateTime) {
this.localDateTime = Objects.requireNonNull(localDateTime);
}

/**
* Return a truncated version of the given date time with millisecond precision.
*/
public static XmlDateTime truncatedToMillis(ZonedDateTime dateTime) {
return new XmlDateTime(dateTime.truncatedTo(ChronoUnit.MILLIS));
}

/**
* Converts the abstract XML dateTime into a {@link ZonedDateTime}. If the underlying date time
* was already zoned, then it is converted to the same instant but in the specified zone.
Expand Down