1import java.util.Calendar;
2
3int year = Calendar.getInstance().get(Calendar.YEAR);
1SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
2Date date = format.parse(datetime);
3SimpleDateFormat df = new SimpleDateFormat("yyyy");
4year = df.format(date);
5
1import java.time.ZoneId;
2import java.util.Date;
3
4new Date().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().getYear();