Java Date函数

阅读更多
public static void main(String[] args) {
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Calendar c=Calendar.getInstance();
        System.out.println(sdf.format(c.getTime()));
        c.add(Calendar.HOUR_OF_DAY, -1);//1小时前
        System.out.println(sdf.format(c.getTime()));
        c=Calendar.getInstance();
        c.add(Calendar.MINUTE, -1);//1分钟前
        System.out.println(sdf.format(c.getTime()));
    }

 

你可能感兴趣的:(Java Date函数)