package tools.util;
import java.sql.Timestamp;
import java.text.MessageFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
/**
* <p>
* Title: 日期处理类
* </p>
* <p>
* Description: 日期处理类
* </p>
*
* @author zbxu
* @version $Revision: 1.3 $ $Date: 2006/10/27 11:46:35 $
*/
/**
* @author zjli
*
*/
public class DateTools
{
// the following const is to define date format.
public static final int FMT_DATE_YYYYMMDD = 1;
public static final int FMT_DATE_YYYYMMDD_HHMMSS = 2;
public static final int FMT_DATE_HHMMSS = 3;
public static final int FMT_DATE_HHMM = 4;
/**
* 将特定格式的字符串转换成java.util.Date对象
* <p>
*
* @param strDate
* a date string
* @param nFmtDate
* specific date string format defined in this class.
* @return Date
* @throws Exception
*/
public static Date parseDate(String strDate, int nFmtDate) throws Exception
{
SimpleDateFormat fmtDate = new SimpleDateFormat();
switch (nFmtDate)
{
default:
case DateTools.FMT_DATE_YYYYMMDD:
fmtDate.applyLocalizedPattern("yyyy-MM-dd");
break;
case DateTools.FMT_DATE_YYYYMMDD_HHMMSS:
fmtDate.applyLocalizedPattern("yyyy-MM-dd HH:mm:ss");
break;
case DateTools.FMT_DATE_HHMM:
fmtDate.applyLocalizedPattern("HH:mm");
break;
case DateTools.FMT_DATE_HHMMSS:
fmtDate