Package java.text

Examples of java.text.DateFormat$DateFormatGetter


    return dateFormat.parse(dateStr);
  }

  protected static String normalizeDateString(DateStringFormatConfig formatConfig, String dateStr)
      throws ParseException {
    DateFormat dateFormat = formatConfig.getDateFormat();
    Date date = dateFormat.parse(dateStr);
    return dateFormat.format(date);
  }
View Full Code Here


    Date date = dateFormat.parse(dateStr);
    return dateFormat.format(date);
  }

  protected static String formatDate(DateStringFormatConfig formatConfig, Date date) {
    DateFormat dateFormat = formatConfig.getDateFormat();
    return dateFormat.format(date);
  }
View Full Code Here

    final String dateFormatStr;
    public DateStringFormatConfig(String dateFormatStr) {
      this.dateFormatStr = dateFormatStr;
    }
    public DateFormat getDateFormat() {
      DateFormat dateFormat = threadLocal.get();
      if (dateFormat == null) {
        dateFormat = new SimpleDateFormat(dateFormatStr);
        threadLocal.set(dateFormat);
      }
      return dateFormat;
View Full Code Here

  private void printMessage(Level level, String message, Throwable throwable) {
    if (!isLevelEnabled(level)) {
      return;
    }
    StringBuilder sb = new StringBuilder(128);
    DateFormat dateFormat = dateFormatThreadLocal.get();
    if (dateFormat == null) {
      dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS");
      dateFormatThreadLocal.set(dateFormat);
    }
    sb.append(dateFormat.format(new Date()));
    sb.append(" [").append(level.name()).append("] ");
    sb.append(className).append(' ');
    sb.append(message);
    printStream.println(sb.toString());
    if (throwable != null) {
View Full Code Here

        (MetaAttributeNames.Numeric.NAMESPACE, MetaAttributeNames.Numeric.PRECISION, Number.class, context);

    if (java.sql.Date.class.isAssignableFrom(type))
    {
      // this includes timestamp ..
      final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.DEFAULT, context.getLocale());
      if (dateFormat instanceof SimpleDateFormat)
      {
        final SimpleDateFormat sdf = (SimpleDateFormat) dateFormat;
        return sdf.toPattern();
      }
      // we cannot come up with a sensible default ..
      return null;
    }
    else if (Time.class.isAssignableFrom(type))
    {
      // this includes timestamp ..
      final DateFormat dateFormat = DateFormat.getTimeInstance(DateFormat.DEFAULT, context.getLocale());
      if (dateFormat instanceof SimpleDateFormat)
      {
        final SimpleDateFormat sdf = (SimpleDateFormat) dateFormat;
        return sdf.toPattern();
      }
      // we cannot come up with a sensible default ..
      return null;
    }
    else if (Date.class.isAssignableFrom(type))
    {
      // this includes timestamp ..
      final DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT,
          context.getLocale());
      if (dateFormat instanceof SimpleDateFormat)
      {
        final SimpleDateFormat sdf = (SimpleDateFormat) dateFormat;
        return sdf.toPattern();
View Full Code Here

   * @throws ClassCastException   if the format given is no DateFormat
   * @throws NullPointerException if the format given is null
   */
  public void setFormatter(final Format format)
  {
    final DateFormat dfmt = (DateFormat) format;
    super.setFormatter(dfmt);
  }
View Full Code Here

    }

    public void testGetDate() throws FtpException {
        Date d1 = new Date();
        Date d2 = new Date(100);
        DateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSSzzz");

        BaseProperties props = new BaseProperties();
        props.setProperty("d1", format.format(d1));
        props.setProperty("d2", "foo");

        assertEquals(d1, props.getDate("d1", format));

        try {
View Full Code Here

     * Return a formatted current date string using the default DateFormat.
     *
     * @return a formatted date string
     */
    public String currentDate() {
        DateFormat format =
            DateFormat.getDateInstance(DateFormat.DEFAULT, getLocale());

        return format.format(new Date());
    }
View Full Code Here

     * @param date the date value to format
     * @return a formatted date string
     */
    public String date(Date date) {
        if (date != null) {
            DateFormat format =
                DateFormat.getDateInstance(DateFormat.DEFAULT, getLocale());

            return format.format(date);

        } else {
            return getEmptyString();
        }
    }
View Full Code Here

     * @param date the date value to format
     * @return a formatted time string
     */
    public String time(Date date) {
        if (date != null) {
            DateFormat format =
                DateFormat.getTimeInstance(DateFormat.DEFAULT, getLocale());

            return format.format(date);

        } else {
            return getEmptyString();
        }
    }
View Full Code Here

TOP

Related Classes of java.text.DateFormat$DateFormatGetter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.