Posted By

rso on 01/14/11


Tagged


Versions (?)

Get Currnet time as a String


 / Published in: Java
 

  1. private String getCurrentTime(){
  2. Calendar c = Calendar.getInstance();
  3. int year = c.get(Calendar.YEAR); //(2)���年���
  4. int month = c.get(Calendar.MONTH) + 1; //(3)�������
  5. int day = c.get(Calendar.DATE); //(4)�������
  6. int hour = c.get(Calendar.HOUR_OF_DAY); //(5)�������
  7. int minute = c.get(Calendar.MINUTE); //(6)�������
  8. int second = c.get(Calendar.SECOND); //(7)�������
  9.  
  10. return (year + "/" + month + "/" + day + " " + hour + ":" + minute + ":" + second);
  11.  
  12. }

Report this snippet  

You need to login to post a comment.