strip time from timestamp

后端 未结 3 1895
没有蜡笔的小新
没有蜡笔的小新 2021-01-23 18:50

Why cannot I clear the time from a timestamp this way:

one day == 24 * 3600 * 1000 == 86400000 milliseconds.

long ms = new Date().getTime();  //Mon Sep 03 10:06         


        
3条回答
  •  悲&欢浪女
    2021-01-23 19:11

    Try this...

    Calendar c = Calendar.getInstance();
    DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
    String strDate = df.format(c.getTime()));
    

    Now this way you can have the another date, and then compare it....as they are now in String format.

提交回复
热议问题