日期格式化
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = null;
try {
date = sdf.parse("2012-10-18 22:22:22");
} catch (ParseException e) {
e.printStackTrace();
}
SimpleDateFormat sdf1 = new SimpleDateFormat("MM.dd");
String dateName = sdf1.format(date);
if ("0".equals(dateName.substring(0, 1))) {
dateName = dateName.substring(1, 5);
int index = dateName.lastIndexOf(".");
if ("0".equals(dateName.substring(index + 1, 3))) {
dateName = dateName.substring(0, index + 1)
+ dateName.substring(index + 2);
}
} else {
int index = dateName.lastIndexOf(".");
if ("0".equals(dateName.substring(index + 1, 4))) {
dateName = dateName.substring(0, index + 1)
+ dateName.substring(index + 2, 5);
}
}
System.out.println(dateName);
输出:10.18
分享到:
相关推荐
易语言格式化时间源码,格式化时间,取格式化日期,取格式化时间,取系统时间
易语言取格式化时间模块源码,取格式化时间模块,取格式化时间
易语言格式化现行时间源码,格式化现行时间,时间_格式化现行时间,取格式化时间_,取现行时间_
资源介绍:。易语言取格式化时间模块源码例程程序根据时间的格式,使用文本操作的方式对其进行格式化。点评:易语言取格式化时间模块源码演示了时间操作和文本操作命令。资源作者:。资源下载:。
JS获取当前时间并格式化"yyyy-MM-dd HH:mm:ss",取时间格式的方法和函数
易语言格式化日期源码,格式化日期,子程序1,取格式化日期
在本篇内容中小编给大家分享了关于易语言取时间年月日格式化的相关知识点以及源码内容,需要的参考下。
Date.prototype.Format 日期格式化 Date.prototype.DateAdd 日期计算 Date.prototype.DateDiff 比较日期差 Date.prototype.toString 日期转字符串 Date.prototype.toArray 日期分割为数组 Date.prototype.DatePart ...
易语言源码易语言取格式化时间模块源码.rar
易语言时间0格式化源码.rar 易语言时间0格式化源码.rar 易语言时间0格式化源码.rar 易语言时间0格式化源码.rar 易语言时间0格式化源码.rar 易语言时间0格式化源码.rar
易语言格式化时间源码,源码实现了易语言的格式化操作。
易语言格式化时间和日期源码
常用的js 方法: 包括 取url 参数,判断对象是否为空,数组取最大值,最小值,日期格式化等等
易语言取格式化时间模块源码例程程序根据时间的格式,使用文本操作的方式对其进行格式化。点评:易语言取格式化时间模块源码演示了时间操作和文本操作命令。三叶易语言自学网
易语言取格式化时间模块源码
计算某个Date的前后时间,格式化Date,获取Date的年月日时分秒部分
易语言取进程创建时间源码,取进程创建时间,取得进程创建时间,格式化时间,OpenProcess,GetProcessTimes,CloseHandle,FileTimeToLocalFileTime,SYSTEMTIME转换成DATE,FileTimeToSystemTime,取格式化时间,取格式化日期