最最最高效方式 获取当天的开始时间和结束时间(Java)

来源:互联网 发布:众安 社交网络事业部 编辑:程序博客网 时间:2024/06/05 05:49
    public static void main(String[] args) {    SimpleDateFormat fmt1= new SimpleDateFormat("yyyy-MM-dd 00:00:00");    SimpleDateFormat fmt2= new SimpleDateFormat("yyyy-MM-dd 23:59:59");        Date now = new Date();    System.out.println("今天的开始时间:"+fmt1.format(now));    System.out.println("今天的结束时间:"+fmt2.format(now));    }


输出结果:

今天的开始时间:2020-12-31 00:00:00

今天的结束时间:2020-12-31 23:59:59


GET到字符串了,再 parse 回 Date 就好了


阅读全文
0 0
原创粉丝点击