KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I need today's date - and zero anything else (" 05/06/08 00:00:00 ") I've tried Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR, 0); Date date1 = calendar.getTime(); System.out.println(date1); Run: (This is seriously messed up) If the hour on the computer is < 12:00 at noon : Sun Mar 08 00:44:39 IST 2009 If the hour on the computer is > 12:00 at noon : Sun Mar 08 12:46:53 IST 2009 So I gave this up. All the Date's setters are deprecated (except the epoch time) - so I don't want to use them either The only thing I could think of is Calendar calendar = Calendar.getInstance(); SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); String sDate = dateFormat.format(calendar.getTime()); Date today = dateFormat.parse(sDate); But this is such a lame code I can't bring myself to write it. Any other option? Thanks!
Tags (comma-separated)
Save Edits
Cancel