JAVA日期格式输出月份前面不想被自动补0
JAVA日期格式输出月份前面不想被自动补0,那么就用SimpleDateFormat("M/dd/yyyy");,一个M。
如果想被自动补0,那么就用MM。SimpleDateFormat("MM/dd/yyyy");
?
? /**?
? ? ?* 返回 2/15/2012 格式的STRING类型,用M月份不会自动补0.用MM,月份会自动补0
? ? ?*/ ?
? ? public static String getTime_0(){ ?
? ? ? ? //此处字符串的格式可以修改 ?
? ? ? ? SimpleDateFormat formatter = new SimpleDateFormat("M/dd/yyyy"); ?
? ? ? ? Date currentTime = new Date();//得到当前系统时间 ?
? ? ? ? String timeStr = formatter.format(currentTime); //将日期时间格式化 ??
? ? ? ?// System.out.println("[1] " + timeStr); ? ??
? ? ? ? //输出:[1] ? ?2009-08-18 20:06:13 ?
? ? ? ? return timeStr;
? ? } ?