-
求出字符“2013-9-8”与“2013-10-1”相差的天数
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.Calendar;
- import java.util.Date;
- 将夜www.jiangyea.com
- public class DayCount {
-
- public static int daysBetween(String lday,String bday) throws ParseException{
- SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
- Calendar cal = Calendar.getInstance();
- cal.setTime(sdf.parse(lday));
- long time1 = cal.getTimeInMillis();
- cal.setTime(sdf.parse(bday));
- long time2 = cal.getTimeInMillis();
-
- long betweenDays=(time2-time1)/(1000*3600*24);
-
- return Integer.parseInt(String.valueOf(betweenDays));
- }
-
- public static void main(String[] args) throws ParseException {
-
- SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date d1=sdf.parse("2013-09-08 10:10:10");
- Date d2=sdf.parse("2013-10-01 00:00:00");
- System.out.println(daysBetween("2013-09-08 10:10:10","2013-10-01 00:00:00"));
- }
- }
-
相关阅读:
李超线段树 [Heoi2013]Segment
[置顶]
九月半集训总结
[置顶]
我想学学
图论+前缀和 任(duty)
模拟 飞(fly)
入坑 可持久化线段树——主席树
一次爆炸的联考
HASH+平衡树 [JSOI2008]火星人prefix
乱搞+STL平衡树 序列
数学+图论 建造游乐场
-
原文地址:https://www.cnblogs.com/jiangye/p/3319147.html
Copyright © 2020-2023
润新知