如果需要获取精确到微秒的时间可以使用下面方法:

 public static String  getNowTime(){
        LocalDateTime localDateTime=LocalDateTime.now();
        return localDateTime.getYear()+"-"+localDateTime.getMonthValue()+"-"+localDateTime.getDayOfMonth()+
                " "+localDateTime.getHour()+":"+localDateTime.getMinute()+":"+localDateTime.getSecond()+"."+
                localDateTime.getNano()/1000;
    }

在这里插入图片描述

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐