Exemplo n.º 1
0
 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";
 }
Exemplo n.º 2
0
  /**
   * 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;
  }
Exemplo n.º 3
0
 /**
  * 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
 }