org.ibankapp.base.util.DateUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of base-util Show documentation
Show all versions of base-util Show documentation
the base moudle of ibankapp series
/*
* iBankApp
*
* License : Apache License,Version 2.0, January 2004
*
* See the LICENSE file in English or LICENSE.zh_CN in chinese
* in the root directory or .
*/
package org.ibankapp.base.util;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
/**
* 日期应用类
*
* @author ibankapp
* @author codelder
* @since 1.0.0
*/
public abstract class DateUtil {
/**
* 按照指定的格式返回当前日期字符串.
*
* @param dateFormat 日期格式
* @return 当前机器日期字符串
*/
public static String getFmtCurrentDateString(String dateFormat) {
return getFmtFromDate(new Date(), dateFormat);
}
/**
* 按照制定格式返回指定日期的日期字符串.
*
* @param date 日期
* @param dateFormat 日期格式
* @return 指定日期的日期字符串
*/
public static String getFmtFromDate(Date date, String dateFormat) {
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
sdf.setTimeZone(TimeZone.getDefault());
return sdf.format(date);
}
}