Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/356.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JAVA/GWT-DateFormat回到1970年1月15日_Java_Gwt - Fatal编程技术网

JAVA/GWT-DateFormat回到1970年1月15日

JAVA/GWT-DateFormat回到1970年1月15日,java,gwt,Java,Gwt,我试图将时间戳解析为人类可读的日期字符串,但是,我一直得到1970年1月15日作为返回 //Here is my formatter DateTimeFormat Format = DateTimeFormat.getFormat("MM/dd/yyyy"); //Here is my timestamp - SHOULD BE AUGUST 16TH, 2010 String date = "1281966439"; //Here is where I create the date, a

我试图将时间戳解析为人类可读的日期字符串,但是,我一直得到1970年1月15日作为返回

//Here is my formatter
DateTimeFormat Format = DateTimeFormat.getFormat("MM/dd/yyyy");

//Here is my timestamp - SHOULD BE AUGUST 16TH, 2010
String date = "1281966439";

//Here is where I create the date, and format it
int intDate = Integer.parseInt(date);
Date eventDate = new Date(intDate);
String eventDateFinal = Format.format(eventDate);

//In this alert, I get 1/15/1970
Window.alert(eventFinal);
我想我可能使用毫秒而不是秒,但是当我以毫秒为单位给它输入值时,我得到了一个异常


有人遇到过这个问题吗?

构造函数应该使用毫秒。记住用它来代替

构造函数应该使用毫秒。记住用它来代替

日期构造函数需要很长的时间,而不是整数,它是从纪元开始的毫秒数

//Here is my formatter
DateTimeFormat Format = DateTimeFormat.getFormat("MM/dd/yyyy");

//Here is my timestamp - SHOULD BE AUGUST 16TH, 2010
String date = "1281966439000";

//Here is where I create the date, and format it
long longDate = Long.parseLong(date);
Date eventDate = new Date(longDate);
String eventDateFinal = Format.format(eventDate);

//In this alert, I get 1/15/1970
Window.alert(eventFinal);

Date构造函数使用的是long,而不是int,它是从历元开始的毫秒数

//Here is my formatter
DateTimeFormat Format = DateTimeFormat.getFormat("MM/dd/yyyy");

//Here is my timestamp - SHOULD BE AUGUST 16TH, 2010
String date = "1281966439000";

//Here is where I create the date, and format it
long longDate = Long.parseLong(date);
Date eventDate = new Date(longDate);
String eventDateFinal = Format.format(eventDate);

//In this alert, I get 1/15/1970
Window.alert(eventFinal);