dateformatter.java

来自「Oracle的J2EE Sample」· Java 代码 · 共 49 行

JAVA
49
字号
/*
 * @author  : Pushkala
 * @version : 1.0
 *
 * Development Environment : Oracle9i JDeveloper
 *
 * Name of the File : DateFormatter.java
 *
 * Creation / Modification History
 *    Pushkala        26-Apr-2002        Created
 *
 */
package oracle.otnsamples.ibfbs.trademanagement.helper;

import java.util.Date; // Utility Packages
import java.text.SimpleDateFormat; // Date Format

/**
 * This class is called from the JSPs to format the Date value
 * into a string to be displayed
 *
 * @version 1.0
 * @since   1.0
 */
public class DateFormatter {

  /**
   * Default empty constructor
   * @since 1.0
   */
  public DateFormatter() {}

  /**
   * This method formats the input Date value according to the input format
   * and returns the formatted string.
   *
   * @param inputDate Input Date value
   * @param format    Format to which the date value has to be converted
   * @return The formatted Date string
   * @since 1.0
   */
  public static String getStringFromDate(Date inputDate, String format) {
    String dateFormat = format; // Date Format
    SimpleDateFormat formatDate = new SimpleDateFormat(dateFormat);

    return formatDate.format(inputDate);
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?