コード例 #1
0
ファイル: CommonFns.java プロジェクト: apextw/zk
 private static final String getRealFormat(
     String pattern, Locale locale, String dateStyle, String timeStyle) {
   int ts, ds;
   if (pattern.isEmpty()) pattern = null;
   ds = toStyle(dateStyle);
   if (ds != -111) {
     ts = toStyle(timeStyle);
     if (ts != -111) {
       return DateFormats.getDateTimeFormat(ds, ts, locale, pattern);
     }
     return DateFormats.getDateFormat(ds, locale, pattern);
   }
   return pattern != null ? pattern : "M/d/yy";
 }
コード例 #2
0
ファイル: Objects.java プロジェクト: fselvatici/zk
  /**
   * Converts any object to a string. If o is an object array, it invokes {@link ArraysX#toString}
   * to make the string more readable.
   */
  public static final String toString(Object o) {
    if (o == null) return null;
    if (o instanceof Date) return DateFormats.format((Date) o, false);
    if (o instanceof Class) {
      final Class cls = (Class) o;
      final String clsnm = cls.getName();
      if (!clsnm.startsWith("$Proxy")) return "class " + clsnm;

      final Class[] ifs = cls.getInterfaces();
      switch (ifs.length) {
        case 0:
          return "class " + clsnm;
        case 1:
          return "proxy " + Objects.toString(ifs[0]);
        default:
          return "proxy " + Objects.toString(ifs);
      }
    }
    if (o.getClass().isArray()) {
      if (o instanceof Object[]) return ArraysX.toString((Object[]) o);
      if (o instanceof int[]) return ArraysX.toString((int[]) o);
      if (o instanceof short[]) return ArraysX.toString((short[]) o);
      if (o instanceof long[]) return ArraysX.toString((long[]) o);
      if (o instanceof double[]) return ArraysX.toString((double[]) o);
      if (o instanceof byte[]) return ArraysX.toString((byte[]) o);
      if (o instanceof boolean[]) return ArraysX.toString((boolean[]) o);
      if (o instanceof char[]) return ArraysX.toString((char[]) o);
      if (o instanceof float[]) return ArraysX.toString((float[]) o);
    }
    return o.toString();
  }
コード例 #3
0
ファイル: Datebox.java プロジェクト: adrgit/zk
  /**
   * Returns the real format, i.e., the combination of the format patterns, such as yyyy-MM-dd.
   *
   * <p>As described in {@link #setFormat}, a developer could specify an abstract name, such as
   * short, or an empty string as the format, and this method will convert it to a real date/time
   * format.
   *
   * @since 5.0.7
   */
  public String getRealFormat() {
    final String format = getFormat();
    if (format == null || format.length() == 0) return getDefaultFormat(); // backward compatible

    int ds = format.indexOf('+');
    if (ds > 0) {
      int ts = toStyle(format.substring(ds + 1));
      if (ts != -111) {
        ds = toStyle(format.substring(0, ds));
        if (ds != -111)
          return DateFormats.getDateTimeFormat(
              ds, ts, _locale, DEFAULT_FORMAT + " " + Timebox.DEFAULT_FORMAT);
      }
    } else {
      ds = toStyle(format);
      if (ds != -111) return DateFormats.getDateFormat(ds, _locale, DEFAULT_FORMAT);
    }
    return format;
  }
コード例 #4
0
ファイル: Datebox.java プロジェクト: adrgit/zk
 /**
  * Returns the default format, which is used when constructing a datebox, or when {@link
  * #setFormat} is called with null or empty.
  *
  * <p>Default: DateFormats.getDateFormat(DEFAULT, null, "yyyy/MM/dd") (see {@link
  * DateFormats#getDateFormat}).
  *
  * <p>Though you might override this method to provide your own default format, it is suggested to
  * specify the format for the current thread with {@link DateFormats#setLocalFormatInfo}.
  */
 protected String getDefaultFormat() {
   return DateFormats.getDateFormat(DateFormat.DEFAULT, _locale, DEFAULT_FORMAT);
   // We use yyyy/MM/dd for backward compatibility
 }