示例#1
0
 public boolean equals(Object obj) {
   if (this == obj) {
     return true;
   }
   if (obj instanceof TimeZoneDisplayKey) {
     TimeZoneDisplayKey other = (TimeZoneDisplayKey) obj;
     return mTimeZone.equals(other.mTimeZone)
         && mStyle == other.mStyle
         && mLocale.equals(other.mLocale);
   }
   return false;
 }
示例#2
0
  /**
   * Set the tz facet.
   *
   * @param tz
   */
  public void setTz(String tz) {
    // Do not make this an exception failure yet.
    //    this.tz = tz;
    //    if (!TimeZone.getTimeZone(tz).equals(timeZone))
    //      throw new IllegalStateException("tz facet must match timezone");
    if (tz == null) return;
    TimeZone newTz = TimeZone.getTimeZone(tz);
    if (newTz == null) {
      System.out.println("no timezone for tz facet:" + tz);
      return;
    }

    // if the timezone isn't what I have now, then we need to
    // clear the fields and recompute them
    if (!newTz.equals(timeZone)) {
      bits0 = bits1 = 0;
    }

    this.tz = tz;
    this.timeZone = newTz;
  }
示例#3
0
  private void writeTimeZone(MarkupWriter writer) {
    if (timeZone == TimeZoneVisibility.NONE) return;

    TimeZone tz = timeZoneTracker.getClientTimeZone();

    writer.element("span", "class", "tx-datefield-timezone");

    switch (timeZone) {
      case DISPLAY:
        writer.write(" ");
        writer.write(tz.getDisplayName(locale));
        break;

      case SELECT:
        writer.element("select", "name", getControlName() + "$timezone");

        for (TimeZone option :
            F.flow(TimeZone.getAvailableIDs()).map(ID_TO_TIME_ZONE).sort(timeZoneComparator)) {
          writer.element("option", "value", option.getID());

          if (tz.equals(option)) writer.attributes("selected", "selected");

          int offset = option.getRawOffset() / (1000 * 60 * 60);

          writer.write(String.format("UTC%+03d %s", offset, option.getID()));

          writer.end();
        }

        writer.end();

      default:
        break;
    }

    writer.end();
  }