显示当前日期和时间在Android应用程序 [英] Display the current time and date in an Android application
本文介绍了显示当前日期和时间在Android应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何显示当前的日期和时间,在Android应用程序?
How do I display the current date and time in an Android application?
推荐答案
好了,没什么难的,因为有几种方法可以做到这一点。我假设你想要把当前的日期和放大器;时间到的TextView
。
Okay, not that hard as there are several methods to do this. I assume you want to put the current date & time into a TextView
.
String currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date());
// textView is the TextView view that should display it
textView.setText(currentDateTimeString);
还有更多的阅读很容易被发现的文件<一个在href="http://developer.android.com/reference/java/text/DateFormat.html#getDateTimeInstance%28%29">here 。在那里你会找到如何更改用于转换格式的更多信息。
There is more to read in the documentation that can easily be found here . There you'll find more information on how to change the format used for conversion.
这篇关于显示当前日期和时间在Android应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文