8小时的误差很可能是时区引起的,北京在东8区。

解决方案 »

  1.   

    我试过用Local.US,但不起作用,最后放弃了这种做法    public static Date getIntervalTime(Date d,String time)
        {
            try
            {
                Calendar c = java.util.Calendar.getInstance();
                SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
                Date dCount = sdf.parse(time);
                c.add(Calendar.SECOND,(dCount.getHours()*3600)+dCount.getSeconds()*60+dCount.getMinutes()*60);
                return c.getTime();
    //System.out.println(dCount.getHours());
    //System.out.println(dCount.getSeconds());
    //System.out.println(dCount.getMinutes());
    //            return getIntervalTime(d,dCount.getTime()) ;        }catch(java.text.ParseException e)
            {
                throw new MFUtilException("Translate date time faield:" + time);
            }
        }用了一些deprecated的方法,虽然不好,但无法子