I would like to get the date & time now and from that do the following: (i) set the month to the first and (ii) zero out everything after the month (iii) calculate the date 1 year and 1 month back and How can I do this using the new Date-Time API of Java?
jshell> import java.time.LocalDateTime;
jshell> import java.time.ZoneId;
jshell> LocalDateTime.now(ZoneId.of("GMT"));
$3 ==> 2021-01-29T01:41:14.273303
jshell> $3.minusYears(1).minusMonths(1).withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0);
$4 ==> 2019-12-01T00:00:00.273303
jshell> $4.atZone(ZoneId.of("GMT"));
$5 ==> 2019-12-01T00:00:00.273303Z[GMT]
jshell> $5.toInstant().toEpochMilli();
$6 ==> 1575158400273
However, what I want is the equivalent of the below:
$4 ==> 2019-12-01T00:00:00.000000
Any ideas on how to do it? Will really appreciate the help.