在新的应用程序中使用Java
8类型(java.time)可能更好。您可以先创建一个
DateTimeFormatter:
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("HH:mm");然后获取当前时间并将其格式化:
Label timeLabel = new Label(LocalTime.now().format(dtf));

在新的应用程序中使用Java
8类型(java.time)可能更好。您可以先创建一个
DateTimeFormatter:
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("HH:mm");然后获取当前时间并将其格式化:
Label timeLabel = new Label(LocalTime.now().format(dtf));