java获取上一年年份输出

package mytest;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class TestLastYear {
    public static void main(String[] args) {
        SimpleDateFormat formats = new SimpleDateFormat("yyyy");
        Calendar c = Calendar.getInstance();
        c.add(Calendar.YEAR,-1);
        Date date =  c.getTime();
        System.out.println(formats.format(date));
        
    }
}

你可能感兴趣的:(java获取上一年年份输出)