Пример #1
0
  /*
   * (non-Javadoc)
   *
   * @see java.text.DateFormat#getDateInstance(int)
   */
  public static DateFormatter getSimpleDateInstance(String format) {
    DateFormatter fmt = new DateFormatter();
    boolean oops = false;
    try {
      fmt.formatterClass = ClassUtil.forName("com.ibm.icu.text.SimpleDateFormat");
      fmt.formatter = ReflectionUtil.construct("com.ibm.icu.text.SimpleDateFormat", format);
    } catch (NoSuchMethodException e) {
      oops = true;
    } catch (IllegalAccessException e) {
      oops = true;
    } catch (InvocationTargetException e) {
      oops = true;
    } catch (ClassNotFoundException e) {
      oops = true;
    } catch (InstantiationException e) {
      oops = true;
    }

    if (oops) {
      fmt.formatterClass = SimpleDateFormat.class;
      fmt.formatter = new SimpleDateFormat(format);
    }

    return fmt;
  }