<dependency>
<groupId>net.time4j</groupId>
<artifactId>time4j-base</artifactId>
<version>4.39</version>
</dependency>
PlainTimestamp now = SystemClock.inLocalView().now();
System.out.println(now);
2022-01-01T12:00:00.000
PlainTimestamp customDateTime = PlainTimestamp.of(2022, 1, 1, 8, 0);
System.out.println(customDateTime);
2022-01-01T08:00:00.000
String formattedDateTime = customDateTime.format(ChronoFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
System.out.println(formattedDateTime);
2022-01-01 08:00:00
PlainTimestamp parsedDateTime = PlainTimestamp.parse("2022-01-01 08:00:00", ChronoFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
System.out.println(parsedDateTime);
2022-01-01T08:00:00.000
PlainDate tomorrow = PlainDate.now().plus(CalendarUnit.DAYS, 1);
System.out.println("Tomorrow: " + tomorrow);
PlainDate nextWeek = PlainDate.now().plus(CalendarUnit.WEEKS, 1);
System.out.println("Next week: " + nextWeek);
PlainTimestamp threeHoursLater = PlainTimestamp.now().plus(3, Timeunit.HOURS);
System.out.println("Three hours later: " + threeHoursLater);
Tomorrow: 2022-01-02
Next week: 2022-01-08
Three hours later: 2022-01-01T15:00:00.000
PlainTimestamp nowUtc = SystemClock.inZonalView(ZoneOffset.UTC).now();
System.out.println("Current time in UTC: " + nowUtc);
PlainTimestamp nowNewYork = SystemClock.inZonalView(ZoneId.of("America/New_York")).now();
System.out.println("Current time in New York: " + nowNewYork);
Current time in UTC: 2022-01-01T12:00:00.000Z
Current time in New York: 2022-01-01T07:00:00.000-05:00[America/New_York]