Android 日期格式化

来源:互联网 发布:手机找不到wifi网络 编辑:程序博客网 时间:2024/05/16 13:42

Android编程权威指南,8.6挑战练习 日期格式化

参考代码: http://developer.android.com/intl/zh-cn/reference/java/text/SimpleDateFormat.html

String format = new String("yyyy-MM-dd HH:mm");SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.CHINA);String dateFormat = sdf.format(mCrime.getDate());mDateButton.setText(dateFormat);//mDateButton.setText(mCrime.getDate().toString());

更好的解决办法
google:android programming challenge solutions
来源:http://forums.bignerdranch.com/viewtopic.php?f=405&t=6443

mDateButton.setText(DateFormat.format("EEEE,MMM dd, yyyy",mCrime.getDate()).toString());
0 0