Man. It seems like there should be a better way of doing this, but for now... here's what I came up with:
private static final SimpleDateFormat noHoursFormatter = new SimpleDateFormat("dd-MMM-yyyy");
private static final SimpleDateFormat millisFormatter = new SimpleDateFormat("SSS-mm-hh-dd-MMM-yyyy");
public static Date pushToBeginningOfDay(Date date){
try {
return noHoursFormatter.parse(noHoursFormatter.format(date));
} catch (ParseException e) {
return null;
}
}
public static Date pushToENDOfDay(Date date){
try {
return millisFormatter.parse("999-59-23-"+noHoursFormatter.format(date));
} catch (ParseException e) {
return null;
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment