How to get current time in formatted form in android?

By | June 4, 2012

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

Leave a Reply

Your email address will not be published. Required fields are marked *