Gol*_*eo8 3 java date simpledateformat
我得到日期字符串 - "2012-04-19 20:51:06".然后我通过SimpleDateFormat获得毫秒时间.
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date d=sdf.parse("2012-04-19 20:51:06");
long milliTime=d.getTime()
Run Code Online (Sandbox Code Playgroud)
然后milliTime是1334839866000L
但是当我将milliTime转换为日期格式String时.结果是"2012-04-19 08:51:06"
long time = 1334839866000L;
Date date = new Date(time);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String t = sdf.format(date);
Run Code Online (Sandbox Code Playgroud)
有什么问题?