Is there a way for me to convert a String in milliseconds to a Date object?
In my program, I have to convert a Date in MM/dd/yyyy format to milliseconds, but then I have to pass that to a Date object.
Below, dateStringFinal
is a String with the format "MM/dd/yyyy" already.
Calendar dateInCal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
try {
dateInCal.setTime(sdf.parse(dateStringFinal));
} catch (java.text.ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String dateInMilli = String.valueOf(dateInCal.getTimeInMillis());
Then I have to set a date variable
someBean.setBeginDate(dateInMilli);
But dateInMilli
should be a Date object. Any ideas?