android – Get Current System Time-ThrowExceptions

Exception or error:

How to get Current System’s Time and Date without using Calender.getInstance()?

How to solve:


Date d = new Date();
CharSequence s  = DateFormat.format("EEEE, MMMM d, yyyy ", d.getTime());

You can edit the format string as you like..


Try this:

//-------- Don't know whether this will work on android or not.
long dtMili = System.currentTimeMillis();
Date dt = new Date(dtMili);


new Date().getTime()


Constructing a new Date will give the current date. thereafter you can use date.setTime( System.currentTimeMillis() ) to update that object


You may try this:

  DateFormat df = DateFormat.getTimeInstance();

  df.format(new Date(System.currentTimeMillis());

Leave a Reply

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