Date nowDate=new Date();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String date_str = dateFormat.format(nowDate);应该返回2012-12-19 18:57:27但是实际返回的是2012-12-19 10:57:27

解决方案 »

  1.   


    加上这句  dateFormat.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
      

  2.   

    Calendar cal = Calendar.getInstance();
    String format ="yyyy-MM-dd HH:mm:ss";
    SimpleDateFormat sdf = new SimpleDateFormat(format);
    String currentDate = sdf.format(cal.getTime());
      

  3.   

    你是在服务器上运行web程序吗?如果是,它取的是server端的程序
      

  4.   

    jvm的系统时间,你的跟实际时间不同步