My problem is to format the date and time variables.
Example: Nächster Vollmond : 2022-06-16T13:53:00.000+0200
I would like to format, beside the mentioned variable, variables individually - other variables only by date, other only by time.
How to do? Any idea?
Thank you very much in advance and best regards
Andreas
Now, depending on what you want there are many different options. If you are just looking for one piece of the object you can use one of the get functions. For example to extract just the hour value you would use:
v_NextVollmond.getHour()
If you want to produce a more complex date and or time format, then you’ll have to use a DateTimeFormatter (which you can read about here):
var dateFormat = Java.type("java.time.format.DateTimeFormatter").ofPattern("yyyy MM dd");
v_NextVollmond = itemRegistry.getItem('LokaleMonddaten_Vollmond').getState().zonedDateTime;
v_NextVollmond.format(dateFormat);