Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
156
rated 0 times [  163] [ 7]  / answers: 1 / hits: 61160  / 12 Years ago, mon, july 30, 2012, 12:00:00

I need to convert JsDate to java.util.Date. I searched but I couldn't find anything. So could you help me with this problem?



Edit: I do this conversion process on GWT screen. I have Datepicker on screen and it gives me JsDate value when I use it's getValue() method. So I'm supposed to put this value into the property of an object which has Date type.



ObjectName.setDate(PickerName.getValue());


I hope my edit will be more clear.



Edit2:



This line is the solution of my problem:



myObject.setDate(new Date((long) myPicker.getValue().getTime()));

More From » java

 Answers
10

The best way of dates conversion is using time in milliseconds, UTC. Both JS Date object and java.util.Date class support conversion to milliseconds (getTime()) and instantiating from milliseconds (using constructor).


[#83983] Saturday, July 28, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tyreem

Total Points: 540
Total Questions: 94
Total Answers: 90

Location: Palestine
Member since Tue, Jul 20, 2021
3 Years ago
;