我想获得的日期。
我使用该日期和月份
int date = cld.get(Calendar.DATE);
int month = cld.get(Calendar.MONTH);
相反,它返回一个INT我想这是一个字符串
。或者完整的日期格式。
Instead of it returning as a int i want it to be a string. or maybe the full date format.
如:12年12月12日 或...
Such as: 12/12/12 or...
2011年8月14日
August 14 2011
如何,我会去这样做?
您想了解的SimpleDateFormat
。
基础知识获取的当前时间ISO8601格式为:
The basics for getting the current time in ISO8601 format:
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mmZ");
String now = df.format(new Date());
对于其它的格式:
For other formats:
DateFormat df = new SimpleDateFormat("MMM d, yyyy");
String now = df.format(new Date());
或
DateFormat df = new SimpleDateFormat("MM/dd/yy");
String now = df.format(new Date());
上一篇:DbDataReader、NextResult() 和填充多个表多个、DbDataReader、NextResult
下一篇:为什么我得到"对象引用未设置为对象&QUOT的实例;访问一个新的数组的元素是什么时候?对象、数组、设置为、实例