DateFormat df = new SimpleDateFormat("hh:mm:ss");
String currentTime = df.format(new Date());
System.out.println(currentTime);输出的结果比当前时间整整少了8小时,请问这是什么原因?

解决方案 »

  1.   

    时区吗,是  (GMT+8:00)北京,重庆,香港特别行政区,乌鲁木齐
      

  2.   

    是啊
    SimpleDateFormatdf = new SimpleDateFormat("hh:mm:ss");
    String currentTime = df.format(new Date());
    System.out.println(currentTime);
      

  3.   

    这样写就可以了
     SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
            String currentTime = df.format(new Date());
            System.out.println(currentTime);将hh大写,如果你不大写的话他指的就是下午早上之类的,不信你试试,我刚才给你试过了,没有问题
      

  4.   

    DateFormat df = new SimpleDateFormat("hh:mm:ss", Locale.CHINA); 
    String currentTime = df.format(new Date()); 
    System.out.println(currentTime); 
      

  5.   


    SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
    更改为这样,就可以了,我刚刚试过了,建议你检查一下你的系统时间和时区。