请写一个日期工具类,具体要求如下: 1、满足常规字符串格式转换 2、能够获取指定日期 3、满足获取指定时间的年、月、日
public class Test { public static void main(String[] args) { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); System.out.println("现在的时间是:" + sdf.format(date)); System.out.println("现在的年份是:" + sdf.format(date).substring(0,4)); System.out.println("现在的月份是:" + sdf.format(date).substring(5,7)); System.out.println("现在的日期是:" + sdf.format(date).substring(8,10)); } }