Android中的时间日期格式如何定义

时间:2014-07-08 13:13:28   收藏:0   阅读:322

1.如何保证日期格式与系统设定的一致:

Date date = new Date(location.getTime());
DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(getApplicationContext());
mTimeText.setText("Time: " + dateFormat.format(date));

注意此处应该应该用 android.text.format.DateFormat 而不是 java.text.DateFormat.

2. 如何自定义日期格式:

event.putExtra("starttime", "12/18/2012");

SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy");
Date date = format.parse(bundle.getString("starttime"));

Android中的时间日期格式如何定义,布布扣,bubuko.com

原文:http://blog.csdn.net/npuhetao/article/details/37500681

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!