public static String lastSecond(String date) {
DateFormat format=new SimpleDateFormat("yyyy-MM-dd");
try {
Date d2=format.parse(date);
int dayMis=1000*60*60*24;//一天的毫秒-1
//返回自 1970 年 1 月 1 日 00:00:00 GMT 以来此 Date 对象表示的毫秒数。
long curMillisecond=d2.getTime();//当天的毫秒
long resultMis=curMillisecond+(dayMis-1); //当天最后一秒
DateFormat format2=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//得到我须要的时间 当天最后一秒
Date resultDate=new Date(resultMis);
String str = format2.format(resultDate);
return str;
}catch (ParseException e){
return date;
}
}
Java gets the time of the last second of the day
Guess you like
Origin blog.csdn.net/zhongzih/article/details/105292772
Ranking