use*_*389 10 android simpledateformat
有没有办法在Java/Android中格式化一个没有前导零的月份?
我懂了:
mTitleText.setText(String.format("Pick Date Time: %tm/%te/%tY %tk:%02d",
mTime,mTime,mTime,mTime,minute));
Run Code Online (Sandbox Code Playgroud)
它返回02/12/2012 13:23当我希望它返回2012年12月12日13:23.
mxr*_*xro 26
对于那些有意避免冗长的JavaDocs的人:
Date mTime = new Date();
String text = new SimpleDateFormat("M/d/yyyy hh:mm").format(mTime);
Run Code Online (Sandbox Code Playgroud)
使用M替代MM和d取代dd将使月份和月份的一天没有可能的话前导零.
String.format()您可以使用该类而不是使用吗SimpleDateFormat?它将执行您想要的操作,但是如果没有看到更多代码,我无法判断您是否有可以使用的日期或日历对象。
http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
| 归档时间: |
|
| 查看次数: |
14728 次 |
| 最近记录: |