EN
Java - format ZonedDateTime to get only hour and minutes in format HH:mm
1 points
Quick solution:
xxxxxxxxxx
1
import java.time.ZonedDateTime;
2
import java.time.format.DateTimeFormatter;
3
4
public class Example {
5
6
public static void main(String[] args) {
7
8
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("HH:mm");
9
ZonedDateTime zonedDateTime = ZonedDateTime.now();
10
11
String format = fmt.format(zonedDateTime);
12
System.out.println(format); // 22:16
13
}
14
}