- String轉(zhuǎn)換成日期
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = formatter.parse("2017-11-11 00:00:00");
- 計算兩個日期之間相差的天數(shù)
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = formatter.parse("2017-11-11 00:00:00");
Date date2 = formatter.parse("2017-12-12 00:00:00");
long delta = date2.getTime() - date.getTime(); // 相差的毫秒數(shù)