Correct Date is not getting added when adding a date to a field

I made a demo

  1. The script needs the datetime value of TODAY. I will use java.time.LocalDate class to get it.
  2. The LocalDate class provides plusDays(int n) and other convenient methods. We can calculate the date of Tomorrow ( today.plusDays(1) ) or Yesterday ( today.minusDays(1) ) just easily.
  3. 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 of java.time.LocalDate into a String.