I made a demo
- The script needs the datetime value of TODAY. I will use
java.time.LocalDateclass to get it. - The
LocalDateclass providesplusDays(int n)and other convenient methods. We can calculate the date of Tomorrow (today.plusDays(1)) or Yesterday (today.minusDays(1)) just easily. - Datetime value displayed in a web page is formatted in various ways. Often date display is tailored according to Locale. E.g, in Japan, I may see 令和2年5月16日. I need to format the today’s date to cope exactly with the format applied in the web page. I will use
java.time.format.DateTimeFormatterto format the instance ofjava.time.LocalDateinto a String.