我怎样才能读取和分析日期和时间的Andr​​oid? [英] How can I read and parse a date and time in Android?

查看:144
本文介绍了我怎样才能读取和分析日期和时间的Andr​​oid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个日期和时间 2011-02-28 7点零零分52秒为字符串。我怎么能读它,然后分析它作为一个日期和时间来比较它的Andr​​oid系统的时间和日期?

解决方案

 字符串的时间; //你的字符串重新presenting时间
SimpleDateFormat的dateFormatter =新的SimpleDateFormat(YYYYMMDDHHMMSS);
日期的startDate = dateFormatter.parse(时间);
 

 新的Date()
 

会给你一个日期重新presenting当前的日期和时间。

I have a date and time 2011-02-28 07:00:52 as a string. How can I read it and then parse it as a date and time to compare it to an Android system time and date?

解决方案

String time; // your string representing the time
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyyMMddHHmmss");
Date startDate = dateFormatter.parse(time);

and

new Date() 

will give you a date representing the current date and time.

这篇关于我怎样才能读取和分析日期和时间的Andr​​oid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆