java 格式化时间字符串

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class Test {
    public static void main(String[] args) {
        // yyyy-MM-dd HH:mm:ss.SSSSSS
        // yyyy-MM-dd HH:mm:ss
        // yyyy-MM-dd HH:mm
        System.out.println(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS").format(LocalDateTime.now()));
    }
// print  2022-08-04 14:44:32.038000
posted @ 2022-08-04 14:46  darling331  阅读(159)  评论(0编辑  收藏  举报