All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ibankapp.base.util.DateUtil Maven / Gradle / Ivy

There is a newer version: 1.0.0-beta.6
Show newest version
/*
 * 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);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy