Posted By

walokra on 04/08/09


Tagged

date java


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

appx
chinyeh


Get the time in defined format


 / Published in: Java
 

  1. /**
  2.  * Get the time in defined format
  3.  *
  4.  * @return String with time
  5.  */
  6. public static String getTime() {
  7. String DATE_FORMAT_NOW = "HH:mm:ss";
  8. Calendar cal = Calendar.getInstance();
  9. SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
  10. return sdf.format(cal.getTime());
  11. }

Report this snippet  

You need to login to post a comment.