📄 comutils.java
字号:
package com.ponyjava.common.util;
import java.io.File;
import java.io.FilenameFilter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 共用辅助方法
*
* 包含一些零散的便捷方法。
*
* @author liufang
*
*/
public class ComUtils {
/**
* 获得当前时间。由于freemarker的日期必须有具体类型,所以使用timestamp。
*
* @return
*/
public static java.sql.Timestamp now() {
return new java.sql.Timestamp(System.currentTimeMillis());
}
/**
* 格式化日期。yyyy-MM-dd
*
* @param date
* @return
*/
public static String dateFormat(Date date) {
return format.format(date);
}
/**
* 格式化日期。yyyy-MM-dd hh-mm-ss
*
* @param date
* @return
*/
public static String dataFormatWhole(Date date) {
return formatw.format(date);
}
public static String formatDate(Date date, int style) {
if (date == null) {
return "";
}
switch (style) {
case 4:
return formats.format(date);
case 3:
return formatm.format(date);
case 2:
return format.format(date);
default:
return formatw.format(date);
}
}
public static final DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
public static final DateFormat formatw = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
public static final DateFormat formatm = new SimpleDateFormat("MM-dd HH:mm");
public static final DateFormat formats = new SimpleDateFormat("MM-dd");
public static FilenameFilter DIR_FILE_FILTER = new FilenameFilter() {
public boolean accept(File dir, String name) {
if (dir.isDirectory()) {
return true;
} else {
return false;
}
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -