首页 > 其他 > 详细

日历类

时间:2020-12-01 21:18:29      阅读:53      评论:0      收藏:0      [点我收藏+]

Calendar calendar = Calendar.getInstance();
demo04(calendar);
}
public static void demo02(Calendar calendar){
calendar.set(Calendar.YEAR, 2050);
int year = calendar.get(Calendar.YEAR);
System.out.println(year);
calendar.set(Calendar.MONTH,12);
System.out.println(calendar.get(Calendar.MONTH));
calendar.set(Calendar.DATE,5);
System.out.println(calendar.get(Calendar.DATE));
}
// 根据日历的规则为给定的日历字段添加或者减去指定的时间量
public static void demo03(Calendar calendar){
calendar.add(Calendar.YEAR,2);
calendar.add(Calendar.MONTH, -3);
System.out.println(calendar.get(Calendar.YEAR));
System.out.println(calendar.get(Calendar.MONTH));
}
public static void demo04(Calendar calendar){
Date time = calendar.getTime();
System.out.println(time);
}

//获取给定的字段值
public static void demo01(Calendar calendar){
int year = calendar.get(Calendar.YEAR);
System.out.println(year);
int month = calendar.get(Calendar.MONTH);
System.out.println(month + 1);
int date = calendar.get(Calendar.DATE);
System.out.println(date);
}

日历类

原文:https://www.cnblogs.com/zlh109/p/14070528.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!