// 参考: https://www.cnblogs.com/blog5277/p/6407463.html
public
class DateTest { // 支持时分秒 private static String LocalDateTimeTest(){ LocalDateTime date = LocalDateTime.now(); String res = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); return res; } // 不支持时分秒 private static String LocalDateTest(){ LocalDate date = LocalDate.now(); String res = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); return res; } // 时间戳 private static long getTimestamp(){ return Timestamp.valueOf(LocalDateTimeTest()).getTime(); } public static void main (String[] args) { System.out.println(LocalDateTimeTest()); System.out.println(LocalDateTest()); System.out.println(getTimestamp(LocalDateTest())); } }

 

相关文章:

  • 2022-01-21
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-14
  • 2021-06-22
  • 2021-09-26
相关资源
相似解决方案