[英]Get the current Date from Google or By LocationManager [GMT +6]
I have created a app which get the time from Mobile. 我创建了一个可以从Mobile获取时间的应用程序。 I want to get the Date from google or by LocationManager .
我想从Google或LocationManager获取日期。 so how can i get it?
所以我怎么能得到呢?
well you can use new Date();
好吧,您可以使用
new Date();
and this will return simply current date and time, also you can format date using SimpleDateFormat
of java.util
package 这将只返回当前日期和时间,也可以使用
java.util
包的SimpleDateFormat
格式化日期
for example: 例如:
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("EEE, MMM dd, yyyy");
try {
String date= simpleDateFormat.format(new Date().getTime());
} catch (ParseException e) {
e.printStackTrace();
}
so this will give output like MON, NOV 27, 2017 所以这将产生类似于MON,2017年11月27日的输出
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.