Skip to content

Instantly share code, notes, and snippets.

@micheleb
Created March 25, 2018 09:23
Show Gist options
  • Save micheleb/c8d198b46181e676fd5619d79d6132d7 to your computer and use it in GitHub Desktop.
Save micheleb/c8d198b46181e676fd5619d79d6132d7 to your computer and use it in GitHub Desktop.
public class TimezoneChange {
private static final ZoneId ZONE = ZoneId.of("Europe/Madrid");
private static final DateTimeFormatter TIME_FORMATTER = new DateTimeFormatterBuilder()
.appendPattern("yyyy-MM-dd'T'HH:mm:ss")
.appendFraction(MILLI_OF_SECOND, 0, 3, true)
.toFormatter();
public static void main(String[] args) {
Instant converted = ZonedDateTime.of(LocalDateTime.parse(startDate, TIME_FORMATTER), ZONE).toInstant();
System.out.println("after changing time zone: " + converted);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment