+ 4
Date and time setting
How to parse date and time to String
2 Antworten
+ 1
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
..
LocalDateTime dt = LocalDateTime.now();
var form1 = DateTimeFormatter .ofPattern("dd.mm.yy HH:mm:ss"); //HH 24h
var form2 = DateTimeFormatter .ofLocalizedDateTime(FormatStyle.SHORT);
System.out.println(form1.format(dt) );
System.out.println(form2.format(dt) );
+ 3
There are various libraries you could use to do so... LocalDate, LocalDateTime and DateTimeFormatter are part of standard libs and provide everything you could need.