获取今天特定的时间

 
 
 
 
获取今天的时间内特定的小时
 public static void main(String[] args) {
     Calendar cal = Calendar.getInstance();
     cal.setTime(new Date());
     cal.add(Calendar.DAY_OF_YEAR, 0);
     cal.set(Calendar.HOUR_OF_DAY, 10);
     cal.set(Calendar.MINUTE, 0);
     cal.set(Calendar.SECOND, 0);
//     System.out.print(cal.getTime().getTime());
     // 添加参数
     String res;
     SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
     long lt = new Long(cal.getTime().getTime());
     Date date = new Date(lt);
     res = simpleDateFormat.format(date);
     System.out.print(res);

     //    String  dateT=cal.getTime()+"";

 }


猜你喜欢

转载自blog.csdn.net/qq_35130066/article/details/80225377