fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.sql.Timestamp;
  4. import java.text.SimpleDateFormat;
  5. import java.util.Calendar;
  6. import java.util.Date;
  7.  
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. long day = System.currentTimeMillis();
  15. Calendar cal = Calendar.getInstance();
  16. SimpleDateFormat month = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss:S");
  17. cal.setTimeInMillis(day);
  18. cal.set(Calendar.HOUR_OF_DAY, 00);
  19. cal.set(Calendar.MINUTE, 00);
  20. cal.set(Calendar.SECOND, 00);
  21. cal.set(Calendar.MILLISECOND, 000);
  22. Date todayDate = cal.getTime();
  23.  
  24. Timestamp current = new Timestamp(todayDate.getTime());
  25. System.out.println(month.format(current));
  26. }
  27. }
Success #stdin #stdout 0.1s 380928KB
stdin
Standard input is empty
stdout
2014-Jan-13 00:00:00:0