开发者

Get Current System Time

How to get Current System's Time and Date without using Calende开发者_StackOverflow中文版r.getInstance()?


Try this:

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

or

new Date().getTime()


try

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

You can edit the format string as you like..


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.setTimeZone(TimeZone.getTimeZone("GMT+05:30"));

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜