I made a demo
- The script needs the datetime value of TODAY. I will use
java.time.LocalDate
class to get it. - The
LocalDate
class 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.DateTimeFormatter
to format the instance ofjava.time.LocalDate
into a String.