LocalTime与LocalDate相反,它只代表一个时间,没有日期。 这意味着我们只能获得当天的当前时间,而不是实际日期:

LocalTime time = LocalTime.now(); // gets the current time
可以按如下方式format

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
System.out.println(time.format(formatter));
得到的结果类似如下:

00:55:58

相关文章:

  • 2021-05-24
  • 2022-01-21
  • 2021-08-17
  • 2021-10-14
  • 2021-06-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-06
  • 2021-12-31
  • 2021-09-19
  • 2021-10-01
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案