dateformatsymbols.java

来自「纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统」· Java 代码 · 共 500 行 · 第 1/2 页

JAVA
500
字号
   * <li>3 - The long name of the time zone (daylight savings time).
   * <li>4 - the short name of the time zone (daylight savings time).
   *
   * @return The list of time zone display strings.
   */
  public String[] [] getZoneStrings ()
  {
    return zoneStrings;
  }

  /**
   * This method sets the list of strings used to display AM/PM values to
   * the specified list.
   * This is a two element <code>String</code> array indexed by
   * <code>Calendar.AM</code> and <code>Calendar.PM</code>
   *
   * @param ampms The new list of AM/PM display strings.
   */
  public void setAmPmStrings (String[] value)
  {
    ampms = value;
  }

  /**
   * This method sets the list of strings used to display time eras to
   * to the specified list.
   * This is a two element <code>String</code>
   * array indexed by <code>Calendar.BC</code> and <code>Calendar.AD</code>.
   *
   * @param eras The new list of era disply strings.
   */
  public void setEras (String[] value)
  {
    eras = value;
  }

  /**
    * This method sets the list of characters used to specific date/time
    * formatting strings.
    * This is an 18 character string that contains the characters
    * that are used in creating the date formatting strings in 
    * <code>SimpleDateFormat</code>.   The following are the character
    * positions in the string and which format character they correspond
    * to (the character in parentheses is the default value in the US English
    * locale):
    * <p>
    * <ul>
    * <li>0 - era (G)
    * <li>1 - year (y)
    * <li>2 - month (M)
    * <li 3 - day of month (d)
    * <li>4 - hour out of 12, from 1-12 (h)
    * <li>5 - hour out of 24, from 0-23 (H)
    * <li>6 - minute (m)
    * <li>7 - second (s)
    * <li>8 - millisecond (S)
    * <li>9 - date of week (E)
    * <li>10 - date of year (D)
    * <li>11 - day of week in month, eg. "4th Thur in Nov" (F)
    * <li>12 - week in year (w)
    * <li>13 - week in month (W)
    * <li>14 - am/pm (a)
    * <li>15 - hour out of 24, from 1-24 (k)
    * <li>16 - hour out of 12, from 0-11 (K)
    * <li>17 - time zone (z)
    * </ul>
    *
    * @param localPatternChars The new format patter characters
    */
  public void setLocalPatternChars (String value)
  {
    localPatternChars = value;
  }

  /**
    * This method sets the list of strings used to display month names.
    * This is a thirteen element
    * string array indexed by <code>Calendar.JANUARY</code> through
    * <code>Calendar.UNDECEMBER</code>.  Note that there are thirteen
    * elements because some calendars have thriteen months.
    *
    * @param months The list of month display strings.
    */
  public void setMonths (String[] value)
  {
    months = value;
  }

  /**
   * This method sets the list of strings used to display abbreviated month
   * names.
   * This is a thirteen element
   * <code>String</code> array indexed by <code>Calendar.JANUARY</code>
   * through <code>Calendar.UNDECEMBER</code>.  Note that there are thirteen
   * elements because some calendars have thirteen months.
   *
   * @param shortMonths The new list of abbreviated month display strings.
   */
  public void setShortMonths (String[] value)
  {
    shortMonths = value;
  }

  /**
   * This method sets the list of strings used to display abbreviated
   * weekday names.
   * This is an eight element
   * <code>String</code> array indexed by <code>Calendar.SUNDAY</code>
   * through <code>Calendar.SATURDAY</code>.  Note that the first element
   * of this array is ignored.
   *
   * @param shortWeekdays This list of abbreviated weekday display strings.
   */
  public void setShortWeekdays (String[] value)
  {
    shortWeekdays = value;
  }

  /**
   * This method sets the list of strings used to display weekday names.
   * This is an eight element
   * <code>String</code> array indexed by <code>Calendar.SUNDAY</code>
   * through <code>Calendar.SATURDAY</code>.  Note that the first element
   * of this array is ignored.
   *
   * @param weekdays This list of weekday display strings.
   */
  public void setWeekdays (String[] value)
  {
    weekdays = value;
  }

  /**
   * This method sets the list of display strings for time zones.
   * This is a two dimensional <code>String</code> array where each row in
   * the array contains five values:
   * <P>
   * <ul>
   * <li>0 - The non-localized time zone id string.
   * <li>1 - The long name of the time zone (standard time).
   * <li>2 - The short name of the time zone (standard time).
   * <li>3 - The long name of the time zone (daylight savings time).
   * <li>4 - the short name of the time zone (daylight savings time).
   *
   * @return The list of time zone display strings.
   */
  public void setZoneStrings (String[][] value)
  {
    zoneStrings = value;
  }

  /* Does a "deep" equality test - recurses into arrays. */
  private static boolean equals (Object x, Object y)
  {
    if (x == y)
      return true;
    if (x == null || y == null)
      return false;
    if (! (x instanceof Object[]) || ! (y instanceof Object[]))
      return x.equals(y);
    Object[] xa = (Object[]) x;
    Object[] ya = (Object[]) y;
    if (xa.length != ya.length)
      return false;
    for (int i = xa.length;  --i >= 0; )
      {
	if (! equals(xa[i], ya[i]))
	  return false;
      }
    return true;
  }

  private static int hashCode (Object x)
  {
    if (x == null)
      return 0;
    if (! (x instanceof Object[]))
      return x.hashCode();
    Object[] xa = (Object[]) x;
    int hash = 0;
    for (int i = 0;  i < xa.length;  i++)
      hash = 37 * hashCode(xa[i]);
    return hash;
  }

  /**
   * This method tests a specified object for equality against this object.
   * This will be true if and only if the specified object:
   * <p>
   * <ul>
   * <li> Is not <code>null</code>.
   * <li> Is an instance of <code>DateFormatSymbols</code>.
   * <li> Contains identical formatting symbols to this object.
   * </ul>
   * 
   * @param obj The <code>Object</code> to test for equality against.
   *
   * @return <code>true</code> if the specified object is equal to this one,
   * </code>false</code> otherwise.
   */
  public boolean equals (Object obj)
  {
    if (! (obj instanceof DateFormatSymbols))
      return false;
    DateFormatSymbols other = (DateFormatSymbols) obj;
    return (equals(ampms, other.ampms)
	    && equals(eras, other.eras)
	    && equals(localPatternChars, other.localPatternChars)
	    && equals(months, other.months)
	    && equals(shortMonths, other.shortMonths)
	    && equals(shortWeekdays, other.shortWeekdays)
	    && equals(weekdays, other.weekdays)
	    && equals(zoneStrings, other.zoneStrings));
  }

  /**
   * Returns a new copy of this object.
   *
   * @param A copy of this object
   */
  public Object clone ()
  {
    try
      {
        return super.clone ();
      } 
    catch (CloneNotSupportedException e) 
      {
        return null;
      }
  }

  /**
   * This method returns a hash value for this object.
   *
   * @return A hash value for this object.
   */
  public int hashCode ()
  {
    return (hashCode(ampms)
	    ^ hashCode(eras)
	    ^ hashCode(localPatternChars)
	    ^ hashCode(months)
	    ^ hashCode(shortMonths)
	    ^ hashCode(shortWeekdays)
	    ^ hashCode(weekdays)
	    ^ hashCode(zoneStrings));
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?