随笔分类 -  Date

日历的设定(Calendar)
摘要://采用单例模式获取日历对象Calendar.getInstance();Calendar c = Calendar.getInstance();//通过日历对象得到日期对象Date d = c.getTime();//设置当前日历日期c.setTime(d);//增加两个月c.add(Calend 阅读全文
posted @ 2021-07-26 14:21 汤姆猫8 阅读(607) 评论(0) 推荐(0)
字符串定义的时间
摘要:SimpleDateFormat ft = new SimpleDateFormat("yyyy.MM.dd"); String a="2020.10.10"; //自定义的时间 Date date1 = ft.parse(a); //转换成date对象 System.out.println(dat 阅读全文
posted @ 2021-07-26 13:51 汤姆猫8 阅读(50) 评论(0) 推荐(0)
Date计算时间差,指定时间
摘要:1.要求: public static void main(String[] args) { // 1900+112 1+2 0+12 8-8 0+0 Date date = new Date(Date.UTC(113, Calendar.MARCH,12,-8,0,0)); // 1900+112 阅读全文
posted @ 2021-07-26 12:52 汤姆猫8 阅读(670) 评论(0) 推荐(0)