dateutils.java
来自「基于Junit的 功能和单元测试的的测试工具。只支持Swing.」· Java 代码 · 共 47 行
JAVA
47 行
package org.uispec4j.utils;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Utility for checking date as String formatted by a date format.
* By default, the date format u
* @see java.text.DateFormat
*/
public class DateUtils {
public static final SimpleDateFormat DEFAULT_DATE_FORMAT = new SimpleDateFormat("yyyy.MM.dd HH:mm");
private static DateFormat dateFormat = DEFAULT_DATE_FORMAT;
private DateUtils() {
// Instanceless class
}
/**
* Returns the date from the given value parsed by the date format.
*/
public static Date getDate(String yyyyMMdd) throws ParseException {
synchronized (dateFormat) {
return dateFormat.parse(yyyyMMdd);
}
}
/**
* Returns the Date as String formated by the date format.
*/
public static String getStandardDate(Date date) {
synchronized (dateFormat) {
return dateFormat.format(date);
}
}
/**
* Sets the date format.
*/
public static void setDateFormat(DateFormat dateFormat) {
DateUtils.dateFormat = dateFormat;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?