Java实现当前时间加减小时(年,月,日,小时,分钟)

     String oneHoursAgoTime="";
        Date dt = new Date();
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd-HH");
        Calendar rightNow = Calendar.getInstance();
        rightNow.setTime(dt);
        //rightNow.add(Calendar.DATE, -1);
        rightNow.add(Calendar.HOUR, -1);
        Date dt1=rightNow.getTime();
        oneHoursAgoTime = sdf.format(dt1);
        return oneHoursAgoTime;

 

上一篇:Java 生成永不重复的订单号


下一篇:Java中日期格式转换