📄 datetimehelper.java
字号:
package edu.yinhe.mis.util;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @author 张崇杰
*
*/
public class DateTimeHelper {
private static SimpleDateFormat FULL_SDF = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
private static SimpleDateFormat DFULL_SDF = new SimpleDateFormat(
"yyyy-MM-dd");
private static SimpleDateFormat DFULL_SDF_SLASH = new SimpleDateFormat(
"yyyy/MM/dd HH:mm");
private static SimpleDateFormat FULL_SDF_NOSP = new SimpleDateFormat(
"yyyyMMddHHmm");
private static SimpleDateFormat DFULL_SDF_CN = new SimpleDateFormat(
"yyyy年MM月dd日");
private static SimpleDateFormat ONLY_TIME = new SimpleDateFormat("HH:mm");
private static SimpleDateFormat MD_TIME = new SimpleDateFormat("MM-dd");
public static String getMDTime(Date date) {
if (date != null) {
return MD_TIME.format(date);
} else {
return "";
}
}
public static String getOnlyTime(Date date) {
if (date != null) {
return ONLY_TIME.format(date);
} else {
return "";
}
}
public static String getFullTimeNoSP(Date date) {
if (date != null) {
return FULL_SDF_NOSP.format(date);
} else {
return "";
}
}
public static String getFullTimeTwo(Date date) {
if (date != null) {
String dateStr = FULL_SDF.format(date);
return dateStr.substring(2, 10);
} else {
return "";
}
}
public static String getFullTime(Date date) {
if (date != null) {
return FULL_SDF.format(date);
} else {
return "";
}
}
public static String getDFullTime(Date date) {
if (date != null) {
return DFULL_SDF.format(date);
} else {
return "";
}
}
public static String getDFullTimeSlash(Date date) {
if (date != null) {
return DFULL_SDF_SLASH.format(date);
} else {
return "";
}
}
public static String getDFullTimeCN(Date date) {
if (date != null) {
return DFULL_SDF_CN.format(date);
} else {
return "";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -