I have a javascript date stored as a String in java. for example: 1327680000000
I want to convert this date from javascript to java date field.
I want it to get displayed in a specific format like "Jan 30 12:25:22" or something like this.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
JavaScript dates and Java dates both share a common characteristic: Their underlying value is the number of milliseconds since The Epoch (Jan 1st, 1970 at midnight GMT). Looking at the value you’ve given, it looks like that’s the value you have in your string. So to convert it to a Java date, parse the string as a
longand use theDate(long)constructor:Then you can use a
DateFormatimplementation likeSimpleDateFormator similar to format it; you might also use aCalendarobject for handling timezones and such.