Friday, March 23, 2012

How to get current time in formatted form in android?


How to get current time in formatted form in android?

Here is a simple code to get the current time in android in your own format.
long tim=System.currentTimeMillis();
 SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
 String curTime =df.format(tim);
 System.out.println("Time : " + curTime);
The output will look like this.
Time : 2011-10-17 09:54:24

No comments: