Java 类org.apache.log4j.helpers.DateTimeDateFormat 实例源码

项目:cacheonix-core    文件:DateLayout.java   
/**
   Sets the DateFormat used to format date and time in the time zone
   determined by <code>timeZone</code> parameter. The {@link DateFormat} used
   will depend on the <code>dateFormatType</code>.

   <p>The recognized types are {@link #NULL_DATE_FORMAT}, {@link
   #RELATIVE_TIME_DATE_FORMAT} {@link
   AbsoluteTimeDateFormat#ABS_TIME_DATE_FORMAT}, {@link
   AbsoluteTimeDateFormat#DATE_AND_TIME_DATE_FORMAT} and {@link
   AbsoluteTimeDateFormat#ISO8601_DATE_FORMAT}. If the
   <code>dateFormatType</code> is not one of the above, then the
   argument is assumed to be a date pattern for {@link
   SimpleDateFormat}.
*/
public
void setDateFormat(String dateFormatType, TimeZone timeZone) {
  if(dateFormatType == null) {
    this.dateFormat = null;
    return;
  } 

  if(dateFormatType.equalsIgnoreCase(NULL_DATE_FORMAT)) {
    this.dateFormat = null;
  } else if (dateFormatType.equalsIgnoreCase(RELATIVE_TIME_DATE_FORMAT)) {
    this.dateFormat =  new RelativeTimeDateFormat();
  } else if(dateFormatType.equalsIgnoreCase(
                           AbsoluteTimeDateFormat.ABS_TIME_DATE_FORMAT)) {
    this.dateFormat =  new AbsoluteTimeDateFormat(timeZone);
  } else if(dateFormatType.equalsIgnoreCase(
                      AbsoluteTimeDateFormat.DATE_AND_TIME_DATE_FORMAT)) {
    this.dateFormat =  new DateTimeDateFormat(timeZone);
  } else if(dateFormatType.equalsIgnoreCase(
                            AbsoluteTimeDateFormat.ISO8601_DATE_FORMAT)) {
    this.dateFormat =  new ISO8601DateFormat(timeZone);
  } else {
    this.dateFormat = new SimpleDateFormat(dateFormatType);
    this.dateFormat.setTimeZone(timeZone);
  }
}
项目:nabs    文件:DateLayout.java   
/**
   Sets the DateFormat used to format date and time in the time zone
   determined by <code>timeZone</code> parameter. The {@link DateFormat} used
   will depend on the <code>dateFormatType</code>.

   <p>The recognized types are {@link #NULL_DATE_FORMAT}, {@link
   #RELATIVE_TIME_DATE_FORMAT} {@link
   AbsoluteTimeDateFormat#ABS_TIME_DATE_FORMAT}, {@link
   AbsoluteTimeDateFormat#DATE_AND_TIME_DATE_FORMAT} and {@link
   AbsoluteTimeDateFormat#ISO8601_DATE_FORMAT}. If the
   <code>dateFormatType</code> is not one of the above, then the
   argument is assumed to be a date pattern for {@link
   SimpleDateFormat}.
*/
public
void setDateFormat(String dateFormatType, TimeZone timeZone) {
  if(dateFormatType == null) {
    this.dateFormat = null;
    return;
  } 

  if(dateFormatType.equalsIgnoreCase(NULL_DATE_FORMAT)) {
    this.dateFormat = null;
  } else if (dateFormatType.equalsIgnoreCase(RELATIVE_TIME_DATE_FORMAT)) {
    this.dateFormat =  new RelativeTimeDateFormat();
  } else if(dateFormatType.equalsIgnoreCase(
                           AbsoluteTimeDateFormat.ABS_TIME_DATE_FORMAT)) {
    this.dateFormat =  new AbsoluteTimeDateFormat(timeZone);
  } else if(dateFormatType.equalsIgnoreCase(
                      AbsoluteTimeDateFormat.DATE_AND_TIME_DATE_FORMAT)) {
    this.dateFormat =  new DateTimeDateFormat(timeZone);
  } else if(dateFormatType.equalsIgnoreCase(
                            AbsoluteTimeDateFormat.ISO8601_DATE_FORMAT)) {
    this.dateFormat =  new ISO8601DateFormat(timeZone);
  } else {
    this.dateFormat = new SimpleDateFormat(dateFormatType);
    this.dateFormat.setTimeZone(timeZone);
  }
}
项目:MacPaf    文件:EventJDOM.java   
public Date getDate() {
    try {
        if (!StringUtils.isEmpty(getDateString())) {
            date = DateTimeDateFormat.getInstance().parse(getDateString());
//          date = dateFormat.parse(getDateString());
        }
    }
    catch (Exception e) {
      // TODO Auto-generated catch block
      log.error("Date Parse error: "+e.getMessage());
    }
    return date;
  }