code_junkie

Generate a current datestamp in Java

Nov 11th, 2011
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. Date myDate = new Date();
  2. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd:HH-mm-ss");
  3. String myDateString = sdf.format(myDate);
  4.  
  5. Date myDate = new Date();
  6. FastDateFormat fdf = FastDateFormat.getInstance("yyyy-MM-dd:HH-mm-ss");
  7. String myDateString = fdf.format(myDate);
  8.  
  9. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd:HH-mm-ss");
  10. Date yourDate = sdf.parse("2008-09-18:22-03-15");
  11.  
  12. Date d = new Date();
  13. String formatted = new SimpleDateFormat ("yyyy-MM-dd:HH-mm-ss").format (d);
  14. System.out.println (formatted);
  15.  
  16. long timestamp = System.currentTimeMillis()
  17.  
  18. final DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd:hh-mm-ss");
  19.  
  20. formatter.format(new Date());
Add Comment
Please, Sign In to add comment