fork download
  1. import java.time.LocalDate;
  2. import java.time.LocalDateTime;
  3. import java.time.OffsetDateTime;
  4. import java.time.ZoneOffset;
  5.  
  6. public class Main {
  7. public static void main(String[] args) {
  8. OffsetDateTime odt = OffsetDateTime.parse("2011-12-03T03:00:00Z");
  9.  
  10. LocalDate locDate = odt.toLocalDate();
  11. System.out.println(locDate);
  12.  
  13. OffsetDateTime odtWithOffsetTwoHours = odt.withOffsetSameInstant(ZoneOffset.of("+02:00"));
  14. System.out.println(odtWithOffsetTwoHours);
  15.  
  16. LocalDateTime ldt = odtWithOffsetTwoHours.toLocalDateTime();
  17. System.out.println(ldt);
  18. }
  19. }
Success #stdin #stdout 0.09s 56812KB
stdin
Standard input is empty
stdout
2011-12-03
2011-12-03T05:00+02:00
2011-12-03T05:00