标签:exce 返回 img date java system -- tin bounds
下面使用对象调用get()方法来获取年月日字段
public int get?(int field)
complete()
方法处理,该过程是与日历系统相关的。field
- 给定的日历字段。ArrayIndexOutOfBoundsException
- 如果指定的字段超出范围( field < 0 || field >= FIELD_COUNT
)。set(int,int)
, complete()
package com.Test01; import java.util.Calendar; public class CalendarDemo { public static void main(String[] args) { //获取对象 Calendar c = Calendar.getInstance(); System.out.println(c); // public int get?(int field) int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH)+1; int date = c.get(Calendar.DATE); System.out.println(year+"年"+month+"月"+date+"日"); } }
package com.Test01; import java.util.Calendar; public class CalendarDemo { public static void main(String[] args) { //获取对象 Calendar c = Calendar.getInstance(); System.out.println(c); // public int get?(int field) c.add(Calendar.YEAR,2); c.add(Calendar.MONTH,-1); c.set(2050,11,25); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH)+1; int date = c.get(Calendar.DATE); System.out.println(year+"年"+month+"月"+date+"日"); } }
字段格式:Calendar.YEAR or MONTH or DATE;
标签:exce 返回 img date java system -- tin bounds
原文地址:https://www.cnblogs.com/lsswudi/p/11405414.html