datetool.java
来自「struts的一些用的书籍」· Java 代码 · 共 27 行
JAVA
27 行
package app04c.util;
/**
* A utility class for parsing and formatting dates using the default pattern.
* If you need more than simple parsing and formatting,
* you can obtain the underlying java.text.DateFormat object.
*/
import java.util.Date;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
public class DateTool {
private static DateFormat dateFormat;
public DateTool(String datePattern) {
dateFormat = new SimpleDateFormat(datePattern);
dateFormat.setLenient(false);
}
public static Date parse(String dateString) throws ParseException {
return dateFormat.parse(dateString);
}
public static String format(Date date) {
return dateFormat.format(date);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?