java.time.temporal


1. Creating a Temporal

LocalDateTime now = LocalDateTime.now();

2. Getting a Field from a Temporal

int year = now.getYear();

3. Setting a Field on a Temporal

LocalDateTime newDate = now.withYear(2020);

4. Adding to a Temporal

LocalDateTime newDate = now.plusYears(1);

5. Subtracting from a Temporal

LocalDateTime newDate = now.minusYears(1);

6. Comparing Temporals

boolean isAfter = now.isAfter(newDate);

7. Checking if a Temporal is Valid

boolean isValid = now.isValid();

8. Getting the Chronology of a Temporal

Chronology chronology = now.getChronology();

9. Converting a Temporal to another Date/Time API

Date date = now.toDate();

10. Creating a TemporalAdjuster

11. Applying a TemporalAdjuster

12. Creating a TemporalQuery

13. Getting a Value from a Temporal using a TemporalQuery

14. Creating a TemporalUnit

15. Adding a TemporalUnit

16. Subtracting a TemporalUnit

17. Calculating the Difference between two Temporals

18. Creating a ZoneId

19. Getting the TimeZone from a ZoneId

20. Creating a ZonedDateTime

21. Converting a ZonedDateTime to a LocalDateTime

22. Creating a DateTimeFormatter

23. Parsing a String into a Temporal

24. Formatting a Temporal into a String

25. Creating a TemporalAmount

26. Adding a TemporalAmount

27. Subtracting a TemporalAmount

28. Calculating the Duration between two Temporals

29. Creating a ChronoField

30. Getting the Value of a ChronoField

31. Setting the Value of a ChronoField

32. Creating a ChronoUnit

33. Adding a ChronoUnit

34. Subtracting a ChronoUnit

35. Creating a ZoneOffset

36. Getting the Hours from a ZoneOffset

37. Converting a ZoneOffset to a ZoneId

38. Creating a Year

39. Getting the Value of a Year

40. Creating a Month

41. Getting the Value of a Month

42. Creating a DayOfWeek

43. Getting the Value of a DayOfWeek

44. Creating a Duration