I am getting surprise result in java servlet. I am passing input parameter(a date) from a jsp to servlet like this:
<input name='date_allow_empty' type='text' value='' class='date picker' />
Date picker is here: http://jsfiddle.net/cBwEK/
let’s say i choosed : 05-04-2012, when i passed this date to servlet then i am getting:
1333620371
But i should get 05-04-2012 in servlet
Servlet:
String t= request.getParameter("date_allow_empty");
out.println(t); //displaying 1333620371 in stead of 05-04-2012
Why this type of result is being displayed in servlet?
That value,
1333620371, is the number of seconds since The Epoch (Jan 1st, 1970). To make a JavaDateout of it, use theDate(long)constructor, which expects milliseconds since The Epoch (so you multiply by 1,000):If you’re getting the value as a
String, you’ll need toparseLongit first, e.g.: