package com.lianxi03;
import java.util.Calendar;
/*
* Calendar:日历,提供了一些操作年月日时的方法
*
* 获取
* 修改
* 添加
*
*
*/
public class Test01 {
public static void main(String[] args) {
Calendar c = Calendar.getInstance();
//把指定的字段修改成指定的值
//c.set(Calendar.DAY_OF_MONTH, 10);
//在指定的字段上加上指定的值
c.add(Calendar.DAY_OF_MONTH, -1);
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH)+1;
int day = c.get(Calendar.DAY_OF_MONTH);
System.out.println(year + "年" + month + "月" + day + "日");
}
}
import java.util.Calendar;
/*
* Calendar:日历,提供了一些操作年月日时的方法
*
* 获取
* 修改
* 添加
*
*
*/
public class Test01 {
public static void main(String[] args) {
Calendar c = Calendar.getInstance();
//把指定的字段修改成指定的值
//c.set(Calendar.DAY_OF_MONTH, 10);
//在指定的字段上加上指定的值
c.add(Calendar.DAY_OF_MONTH, -1);
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH)+1;
int day = c.get(Calendar.DAY_OF_MONTH);
System.out.println(year + "年" + month + "月" + day + "日");
}
}