コード例 #1
0
ファイル: Datebox.java プロジェクト: adrgit/zk
  protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer)
      throws java.io.IOException {
    super.renderProperties(renderer);
    if (!_btnVisible) renderer.render("buttonVisible", false);
    if (!_lenient) renderer.render("lenient", false);
    if (_dtzonesReadonly) renderer.render("timeZonesReadonly", true);
    if (_dtzones != null) {
      StringBuffer sb = new StringBuffer();
      for (int i = 0; i < _dtzones.size(); i++) {
        if (i != 0) sb.append(',');
        TimeZone tz = _dtzones.get(i);
        sb.append(tz.getID());
      }
      renderer.render("displayedTimeZones", sb.toString());
    }

    render(renderer, "weekOfYear", _weekOfYear);

    if (_tzone != null) renderer.render("timeZone", _tzone.getID());
    renderer.render("localizedFormat", getLocalizedFormat());

    String unformater = getUnformater();
    if (!Strings.isBlank(unformater)) renderer.render("unformater", unformater);

    if (_locale != null) renderer.render("localizedSymbols", getRealSymbols(_locale, this));
  }
コード例 #2
0
ファイル: TimeZoneTest.java プロジェクト: chealwoo/java-study
  @Test
  public void badTimeZoneIdTest() {

    String badId = "This is bad ID";
    String goodId = "PST";
    TimeZone badTimezone = TimeZone.getTimeZone(badId);

    assertEquals("GMT", badTimezone.getID());

    TimeZone goodTimezone_ = TimeZone.getTimeZone(goodId);
    assertEquals("PST", goodTimezone_.getID());
  }
コード例 #3
0
 public void test_hasSameRulesLjava_util_TimeZone() {
   TimeZone tz1 = TimeZone.getTimeZone("America/Denver");
   TimeZone tz2 = TimeZone.getTimeZone("America/Phoenix");
   assertEquals(tz1.getDisplayName(false, 0), tz2.getDisplayName(false, 0));
   // Arizona doesn't observe DST. See http://phoenix.about.com/cs/weather/qt/timezone.htm
   assertFalse(tz1.hasSameRules(tz2));
   assertFalse(tz1.hasSameRules(null));
   tz1 = TimeZone.getTimeZone("America/New_York");
   tz2 = TimeZone.getTimeZone("US/Eastern");
   assertEquals(tz1.getDisplayName(), tz2.getDisplayName());
   assertFalse(tz1.getID().equals(tz2.getID()));
   assertTrue(tz2.hasSameRules(tz1));
   assertTrue(tz1.hasSameRules(tz1));
 }
コード例 #4
0
  /**
   * Gets an Olson ID corresponding to the information saved and a suggestion. First it looks for a
   * cached ID. If it is not found, it checks if the saved name simply contains an Olson ID. If it
   * does, it will be returned as the result without further investigation. If that is not the case,
   * the ID of the suggested time zone is checked against the transitions and offsets saved. If this
   * also fails, it looks for a matching ID among the favorite ones. Otherwise it looks for it among
   * all available IDs with the same basic offset.
   *
   * @param suggested the suggested time zone (as a TimeZone object)
   * @return a string containing the Olson ID or null if no matching ID is found
   */
  public String toID(TimeZone suggested) {

    if (suggested != null) {
      return toID(suggested.getID());
    }
    return toID((String) null);
  }
コード例 #5
0
ファイル: CalendarTimeZone.java プロジェクト: so1999/idearepo
  public static void main(String[] args) throws ParseException {
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a");
    String dateInString = "2015-12-10 04:52:30 下午";
    Date date = formatter.parse(dateInString);
    TimeZone tz = TimeZone.getDefault();
    // From TimeZone Asia/Shanghai
    System.out.println("TimeZone: " + tz.getID() + "-" + tz.getDisplayName());
    System.out.println("TimeZone: " + tz);
    System.out.println("Date: " + formatter.format(date));

    // To TimeZone America/New_York
    SimpleDateFormat sdfAmerica = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss a");
    TimeZone tzInAmerica = TimeZone.getTimeZone("America/New_York");
    sdfAmerica.setTimeZone(tzInAmerica);

    Calendar calendar = new GregorianCalendar();

    // System.out.println("\nAmericaTimeZone: "
    // +tzInAmerica.getID()+"-"+tzInAmerica.getDisplayName());
    // System.out.println("AmericaTimeZone: " +tzInAmerica);
    // System.out.println("Date+Formatter: " +sdfAmerica.format(calendar.getTime()));

    calendar.setTime(date);
    calendar.setTimeZone(tzInAmerica);
    System.out.println(calendar.get(Calendar.YEAR));
    System.out.println(calendar.get(Calendar.AM_PM));
  }
コード例 #6
0
ファイル: PrintLocale.java プロジェクト: coffeefoam/isis
  public static void main(final String[] args) {
    if (args.length >= 2) {
      final String localeSetting = args[0];
      System.out.println("Setting Locale to " + localeSetting + "\n");
      Locale.setDefault(new Locale(localeSetting));

      final String timezoneSetting = args[1];
      System.out.println("Setting TimeZone to " + timezoneSetting + "\n");
      TimeZone.setDefault(TimeZone.getTimeZone(timezoneSetting));
    }

    final Locale locale = Locale.getDefault();
    System.out.println("Locale");
    System.out.println("Code: " + locale.toString());
    try {
      System.out.println("Country: " + locale.getISO3Country());
    } catch (final MissingResourceException e) {
      System.out.println("Country: " + e.getMessage());
    }
    try {
      System.out.println("Language: " + locale.getISO3Language());
    } catch (final MissingResourceException e) {
      System.out.println("Language: " + e.getMessage());
    }

    System.out.println("\nTimezone");
    final TimeZone timezone = TimeZone.getDefault();
    System.out.println("Code: " + timezone.getID());
    System.out.println("Name: " + timezone.getDisplayName());
    System.out.println("Offset: " + timezone.getRawOffset() / (1000 * 60 * 60));
    System.out.println("DST: " + timezone.getDSTSavings() / (1000 * 60 * 60));
  }
コード例 #7
0
ファイル: FormatUtil.java プロジェクト: ringgi/railo
  public static DateFormat[] getDateTimeFormats(Locale locale, TimeZone tz, boolean lenient) {

    String id = "dt-" + locale.hashCode() + "-" + tz.getID() + "-" + lenient;
    DateFormat[] df = (DateFormat[]) formats.get(id);
    if (df == null) {
      df =
          new DateFormat[] {
            DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, locale),
            DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.LONG, locale),
            DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.MEDIUM, locale),
            DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.SHORT, locale),
            DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.FULL, locale),
            DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale),
            DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.MEDIUM, locale),
            DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT, locale),
            DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.FULL, locale),
            DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.LONG, locale),
            DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, locale),
            DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT, locale),
            DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.FULL, locale),
            DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG, locale),
            DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale),
            DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale)
          };
      for (int i = 0; i < df.length; i++) {
        df[i].setLenient(lenient);
        df[i].setTimeZone(tz);
      }

      formats.put(id, df);
    }

    return df;
  }
コード例 #8
0
 public void testParseTimeZoneEndToEnd() {
   TimeZone tz = CalendarUtilities.tziStringToTimeZone(AMERICA_DAWSON_TIME);
   assertEquals("America/Dawson", tz.getID());
   tz = CalendarUtilities.tziStringToTimeZone(ASIA_CALCUTTA_TIME);
   assertEquals("Asia/Calcutta", tz.getID());
   tz = CalendarUtilities.tziStringToTimeZone(AUSTRALIA_ACT_TIME);
   assertEquals("Australia/ACT", tz.getID());
   tz = CalendarUtilities.tziStringToTimeZone(EUROPE_MOSCOW_TIME);
   assertEquals("Europe/Moscow", tz.getID());
   tz = CalendarUtilities.tziStringToTimeZone(GMT_UNKNOWN_DAYLIGHT_TIME);
   int bias = tz.getOffset(System.currentTimeMillis());
   assertEquals(0, bias);
   // Make sure non-DST TZ's work properly
   tz = CalendarUtilities.tziStringToTimeZone(ARIZONA_TIME);
   assertEquals("America/Phoenix", tz.getID());
 }
コード例 #9
0
 /**
  * Sanity test for time zone generation. Most important, make sure that we can run through all of
  * the time zones without generating an exception. Second, make sure that we're finding rules for
  * at least 90% of time zones that use daylight time (empirically, it's more like 95%). Log those
  * without rules.
  *
  * @throws IOException
  */
 public void testTimeZoneToVTimezone() throws IOException {
   SimpleIcsWriter writer = new SimpleIcsWriter();
   int rule = 0;
   int nodst = 0;
   int norule = 0;
   ArrayList<String> norulelist = new ArrayList<String>();
   for (String tzs : TimeZone.getAvailableIDs()) {
     TimeZone tz = TimeZone.getTimeZone(tzs);
     writer = new SimpleIcsWriter();
     CalendarUtilities.timeZoneToVTimezone(tz, writer);
     String vc = writer.toString();
     boolean hasRule = vc.indexOf("RRULE") > 0;
     if (hasRule) {
       rule++;
     } else if (tz.useDaylightTime()) {
       norule++;
       norulelist.add(tz.getID());
     } else {
       nodst++;
     }
   }
   assertTrue(norule < rule / 10);
   Log.d("TimeZoneGeneration", "Rule: " + rule + ", No DST: " + nodst + ", No rule: " + norule);
   for (String nr : norulelist) {
     Log.d("TimeZoneGeneration", "No rule: " + nr);
   }
 }
コード例 #10
0
ファイル: TimeZoneTest.java プロジェクト: chealwoo/java-study
  // @Ignore
  @Test
  public void allTimeZoneTest() {

    String[] tzIds = TimeZone.getAvailableIDs();

    System.out.printf(
        "NUM) %32s, %5s \t,%15s\t,%15s,%6s\n",
        "Time Zone", "inDST", "offset", "DSTSavings", "useDST");
    for (int i = 0; i < tzIds.length; i++) {
      String string = tzIds[i];
      TimeZone timezone = TimeZone.getTimeZone(string);
      Date date = new Date();
      // System.out.println(i + ") " + timezone.getID() + ", offset " +
      // timezone.getOffset(date.getTime()) + ", DSTSavings " +
      // timezone.getDSTSavings());
      System.out.printf(
          "%3d) %32s, %5s \t,%15d\t,%15d,%6s\n",
          i,
          timezone.getID(),
          timezone.inDaylightTime(date),
          timezone.getOffset(date.getTime()),
          timezone.getDSTSavings(),
          timezone.useDaylightTime());
    }

    assertTrue(true);
  }
コード例 #11
0
  /**
   * Sets the <code>TimeZone</code> that is returned by the <code>getDefault</code> method. If
   * <code>zone</code> is null, reset the default to the value it had originally when the VM first
   * started.
   *
   * @param tz the new default time zone
   * @stable ICU 2.0
   */
  public static synchronized void setDefault(TimeZone tz) {
    defaultZone = tz;
    java.util.TimeZone jdkZone = null;
    if (defaultZone instanceof JavaTimeZone) {
      jdkZone = ((JavaTimeZone) defaultZone).unwrap();
    } else {
      // Keep java.util.TimeZone default in sync so java.util.Date
      // can interoperate with com.ibm.icu.util classes.

      if (tz != null) {
        if (tz instanceof com.ibm.icu.impl.OlsonTimeZone) {
          // Because of the lack of APIs supporting historic
          // zone offset/dst saving in JDK TimeZone,
          // wrapping ICU TimeZone with JDK TimeZone will
          // cause historic offset calculation in Calendar/Date.
          // JDK calendar implementation calls getRawOffset() and
          // getDSTSavings() when the instance of JDK TimeZone
          // is not an instance of JDK internal TimeZone subclass
          // (sun.util.calendar.ZoneInfo).  Ticket#6459
          String icuID = tz.getID();
          jdkZone = java.util.TimeZone.getTimeZone(icuID);
          if (!icuID.equals(jdkZone.getID())) {
            // JDK does not know the ID..
            jdkZone = null;
          }
        }
        if (jdkZone == null) {
          jdkZone = TimeZoneAdapter.wrap(tz);
        }
      }
    }
    java.util.TimeZone.setDefault(jdkZone);
  }
コード例 #12
0
  /**
   * Gets the display name for the specified Timezone ID. If the ID matches the list of IDs that
   * need to be have their default display names overriden, use the pre-set display name from
   * R.arrays.
   *
   * @param id The timezone ID.
   * @param daylightTime True for daylight time, false for standard time
   * @return The display name of the timezone. This will just use the default display name, except
   *     that certain timezones have poor defaults, and should use the pre-set override labels from
   *     R.arrays.
   */
  private String getDisplayName(TimeZone tz, boolean daylightTime) {
    if (mOverrideIds == null || mOverrideLabels == null) {
      // Just in case they somehow didn't get loaded correctly.
      return tz.getDisplayName(daylightTime, TimeZone.LONG, Locale.getDefault());
    }

    for (int i = 0; i < mOverrideIds.length; i++) {
      if (tz.getID().equals(mOverrideIds[i])) {
        if (mOverrideLabels.length > i) {
          return mOverrideLabels[i];
        }
        Log.e(
            TAG,
            "timezone_rename_ids len="
                + mOverrideIds.length
                + " timezone_rename_labels len="
                + mOverrideLabels.length);
        break;
      }
    }

    // If the ID doesn't need to have the display name overridden, or if the labels were
    // malformed, just use the default.
    return tz.getDisplayName(daylightTime, TimeZone.LONG, Locale.getDefault());
  }
コード例 #13
0
  @Override
  public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {
    if (!children.get(0).evaluate(tuple, ptr)) {
      return false;
    }

    String timezone = Bytes.toString(ptr.get(), ptr.getOffset(), ptr.getLength());

    if (!children.get(1).evaluate(tuple, ptr)) {
      return false;
    }

    if (!cachedTimeZones.containsKey(timezone)) {
      TimeZone tz = TimeZone.getTimeZone(timezone);
      if (!tz.getID().equals(timezone)) {
        throw new IllegalDataException("Invalid timezone " + timezone);
      }
      cachedTimeZones.put(timezone, tz);
    }

    Date date = (Date) PDate.INSTANCE.toObject(ptr, children.get(1).getSortOrder());
    int offset = cachedTimeZones.get(timezone).getOffset(date.getTime());

    ptr.set(PInteger.INSTANCE.toBytes(offset / MILLIS_TO_MINUTES));
    return true;
  }
コード例 #14
0
ファイル: TidReader.java プロジェクト: NTNU-MCS/neptus
 /**
  * Parses the comment lines for harbor info and time zone.
  *
  * @param line
  */
 private void processComment(String line) {
   if (asReadTheHarborInfo && asReadTheTimeZoneInfo) return;
   if (isCommentLine(line)) {
     if (!asReadTheHarborInfo) {
       String val = extractValueWithHeader(line, TidWriter.HARBOR_STR);
       if (val != null && !val.isEmpty()) {
         harbor = val;
         asReadTheHarborInfo = true;
         return;
       }
     }
     if (!asReadTheTimeZoneInfo) {
       String val = extractValueWithHeader(line, TidWriter.TIMEZONE_STR);
       if (val != null && !val.isEmpty()) {
         TimeZone tz = TimeZone.getTimeZone(val);
         if (tz.getID().equalsIgnoreCase(val)) {
           dateTimeFormatterUTC.setTimeZone(tz);
           dateTimeFormatterUTC2.setTimeZone(tz);
         } else {
           NeptusLog.pub().error("Error processing time zone, using UTC.");
         }
         asReadTheTimeZoneInfo = true;
         return;
       }
     }
   }
 }
コード例 #15
0
ファイル: FormatUtil.java プロジェクト: ringgi/railo
  /**
   * CFML Supported LS Formats
   *
   * @param locale
   * @param tz
   * @param lenient
   * @return
   */
  public static DateFormat[] getCFMLFormats(TimeZone tz, boolean lenient) {
    String id = "cfml-" + Locale.ENGLISH.hashCode() + "-" + tz.getID() + "-" + lenient;
    DateFormat[] df = (DateFormat[]) formats.get(id);
    if (df == null) {
      df =
          new SimpleDateFormat[] {
            new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH),
            new SimpleDateFormat("MMM dd, yyyy H:mm:ss a", Locale.ENGLISH),
            new SimpleDateFormat("MMMM dd, yyyy HH:mm:ss a zzz", Locale.ENGLISH),
            new SimpleDateFormat("MMMM d yyyy HH:mm:ss", Locale.ENGLISH),
            new SimpleDateFormat("MMMM d yyyy HH:mm", Locale.ENGLISH),
            new SimpleDateFormat("EEE, MMM dd, yyyy HH:mm:ss", Locale.ENGLISH),
            new SimpleDateFormat("EEEE, MMMM dd, yyyy h:mm:ss a zzz", Locale.ENGLISH),
            new SimpleDateFormat("dd-MMM-yy HH:mm a", Locale.ENGLISH),
            new SimpleDateFormat("dd-MMMM-yy HH:mm a", Locale.ENGLISH),
            new SimpleDateFormat("EE, dd MMM yyyy HH:mm:ss zz", Locale.ENGLISH),
            new SimpleDateFormat("EEE d, MMM yyyy HH:mm:ss zz", Locale.ENGLISH),
            new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH),
            new SimpleDateFormat("MMMM, dd yyyy hh:mm:ss", Locale.ENGLISH),
            new SimpleDateFormat("yyyy/MM/dd hh:mm:ss zz", Locale.ENGLISH)
            // ,new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss",Locale.ENGLISH)
          };

      for (int i = 0; i < df.length; i++) {
        df[i].setLenient(lenient);
        df[i].setTimeZone(tz);
      }
      formats.put(id, df);
    }
    return df;
  }
コード例 #16
0
 public LogbackAccessRequestLayout(Context context, TimeZone timeZone) {
   setOutputPatternAsHeader(false);
   setPattern(
       "%h %l %u [%t{dd/MMM/yyyy:HH:mm:ss Z,"
           + timeZone.getID()
           + "}] \"%r\" %s %b \"%i{Referer}\" \"%i{User-Agent}\" %D");
   setContext(context);
 }
コード例 #17
0
ファイル: TimeZonesActivity.java プロジェクト: zieglerm/enh
 @Override
 public String toString() {
   String result = timeZone.getID();
   if (timeZone.equals(TimeZone.getDefault())) {
     result += " (default)";
   }
   return result;
 }
コード例 #18
0
  @Test
  public void testGetCurrentTimeZone() {
    final TimeZone timeZone = TimeZone.getTimeZone("America/Los_Angeles");
    when(sessionService.getAttribute(I18NConstants.TIMEZONE_SESSION_ATTR_KEY)).thenReturn(timeZone);

    final TimeZone currentTimeZone = i18NService.getCurrentTimeZone();
    assertEquals(
        "Wrong current time zone ID! Should be: '"
            + timeZone.getID()
            + "' but was: '"
            + currentTimeZone.getID()
            + "'.",
        timeZone.getID(),
        currentTimeZone.getID());

    verify(sessionService, times(1)).getAttribute(Mockito.anyString());
  }
コード例 #19
0
ファイル: StringUtil.java プロジェクト: shadewly/zhaoshifu
 /**
  * Parse the given {@code timeZoneString} value into a {@link TimeZone}.
  *
  * @param timeZoneString the time zone String, following {@link TimeZone#getTimeZone(String)} but
  *     throwing {@link IllegalArgumentException} in case of an invalid time zone specification
  * @return a corresponding {@link TimeZone} instance
  * @throws IllegalArgumentException in case of an invalid time zone specification
  */
 public static TimeZone parseTimeZoneString(String timeZoneString) {
   TimeZone timeZone = TimeZone.getTimeZone(timeZoneString);
   if ("GMT".equals(timeZone.getID()) && !timeZoneString.startsWith("GMT")) {
     // We don't want that GMT fallback...
     throw new IllegalArgumentException(
         "Invalid time zone specification '" + timeZoneString + "'");
   }
   return timeZone;
 }
コード例 #20
0
ファイル: TimeZoneBean.java プロジェクト: shred/cilla
 @Override
 public String getAsString(FacesContext fc, UIComponent uic, Object o) {
   try {
     TimeZone tz = (TimeZone) o;
     return tz.getID();
   } catch (Exception ex) {
     throw new ConverterException(ex);
   }
 }
コード例 #21
0
 private static Map<String, Object> createDisplayEntry(
     TimeZone tz, String gmtOffsetString, String displayName, int offsetMillis) {
   Map<String, Object> map = new HashMap<String, Object>();
   map.put(KEY_ID, tz.getID());
   map.put(KEY_DISPLAYNAME, displayName);
   map.put(KEY_GMT, gmtOffsetString);
   map.put(KEY_OFFSET, offsetMillis);
   return map;
 }
コード例 #22
0
  /**
   * Returns the time zone of the server <br>
   * <br>
   * <b>Usage:</b> MEETZN = T2ZoneString();
   *
   * @param time The time in miliseconds
   * @return String The time zone
   */
  public String date2ZoneString(long time) {
    Calendar C = makeCalendar(time);
    TimeZone CurrentZone;
    CurrentZone = C.getTimeZone();
    String theID = CurrentZone.getID();
    theID = getTheIntZoneID(CurrentZone.getRawOffset());

    return theID;
  }
コード例 #23
0
  @Inject
  public Export2iCalConverter(
      TimeZoneConverter timezoneConverter,
      RaplaLocale raplaLocale,
      Logger logger,
      ClientFacade facade)
      throws RaplaException {
    this.timezoneConverter = timezoneConverter;
    this.facade = facade;
    this.raplaLocale = raplaLocale;
    this.logger = logger;
    TimeZone zone = timezoneConverter.getImportExportTimeZone();

    calendar = raplaLocale.createCalendar();
    DynamicType[] dynamicTypes =
        facade.getDynamicTypes(DynamicTypeAnnotations.VALUE_CLASSIFICATION_TYPE_RESOURCE);
    for (DynamicType type : dynamicTypes) {
      if (type.getAnnotation(DynamicTypeAnnotations.KEY_LOCATION) != null) {
        hasLocationType = true;
      }
    }
    CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_VALIDATION, true);

    RaplaConfiguration config =
        facade
            .getSystemPreferences()
            .getEntry(Export2iCalPlugin.ICAL_CONFIG, new RaplaConfiguration());
    global_export_attendees =
        config
            .getChild(Export2iCalPlugin.EXPORT_ATTENDEES)
            .getValueAsBoolean(Export2iCalPlugin.DEFAULT_exportAttendees);
    global_export_attendees_participation_status =
        config
            .getChild(Export2iCalPlugin.EXPORT_ATTENDEES_PARTICIPATION_STATUS)
            .getValue(Export2iCalPlugin.DEFAULT_attendee_participation_status);

    try {
      exportAttendeesAttribute =
          config.getChild(Export2iCalPlugin.EXPORT_ATTENDEES_EMAIL_ATTRIBUTE).getValue();
    } catch (ConfigurationException e) {
      exportAttendeesAttribute = "";
      getLogger().info("ExportAttendeesMailAttribute is not set. So do not export as meeting");
    }
    if (zone != null) {
      final String timezoneId = zone.getID();

      try {
        TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
        timeZone = registry.getTimeZone(timezoneId);
      } catch (Exception rc) {
        final VTimeZone vTimeZone = new VTimeZone();
        timeZone = new net.fortuna.ical4j.model.TimeZone(vTimeZone);
        final int rawOffset = zone.getRawOffset();
        timeZone.setRawOffset(rawOffset);
      }
    }
  }
コード例 #24
0
ファイル: LogonResult.java プロジェクト: jdurani/teiid
 @Override
 public void writeExternal(ObjectOutput out) throws IOException {
   out.writeObject(vdbName);
   out.writeObject(sessionToken);
   out.writeObject(timeZone);
   out.writeObject(clusterName);
   out.writeInt(vdbVersion);
   ExternalizeUtil.writeMap(out, addtionalProperties);
   out.writeUTF(timeZone.getID());
 }
コード例 #25
0
  /**
   * Fairfieldの公式の確認。
   *
   * @param pattern
   * @param timeZone
   * @param failsOnAssert
   * @throws ParseException
   */
  private void assertFairfieldDays(String pattern, TimeZone timeZone, boolean failsOnAssert)
      throws ParseException {
    SimpleDateFormat sdf = new SimpleDateFormat(pattern);
    sdf.setTimeZone(timeZone);
    SafeDateFormat safe = SafeDateFormat.getInstance(pattern, timeZone);

    boolean passed = true;
    StringBuilder failedDates = new StringBuilder();
    String minYear = null;
    String maxYear = null;
    long ms = 0;
    for (int i = -100000; i < 100000; i++) {
      ms = 86400000L * i;
      String date = sdf.format(new Date(ms));
      long msDate = sdf.parse(date).getTime();
      if (failsOnAssert) {
        assertEquals(msDate, safe.parse(date));
        assertEquals(date, safe.format(msDate));
      }
      if (msDate != safe.parse(date)) {
        passed = false;
        int diff = (int) (msDate - safe.parse(date)) / 1000;
        failedDates.append('p').append(date).append('-').append(diff).append(',');
      }
      if (!date.equals(safe.format(msDate))) {
        passed = false;
        failedDates.append('f').append(date).append(',');
      }

      maxYear = date.substring(0, 4);
      if (minYear == null) {
        minYear = maxYear;
      }
    }

    if (passed) {
      System.out.printf(
          "passed %s from %s year till %s year\n", timeZone.getID(), minYear, maxYear);
    } else {
      failedDates.setLength(failedDates.length() - 1);
      System.out.printf("FAILED! %s %s\n", timeZone.getID(), failedDates.toString());
    }
  }
コード例 #26
0
 /**
  * Gets the default <code>TimeZone</code> for this host. The source of the default <code>TimeZone
  * </code> may vary with implementation.
  *
  * @return a default <code>TimeZone</code>.
  * @stable ICU 2.0
  */
 public static synchronized TimeZone getDefault() {
   if (defaultZone == null) {
     if (TZ_IMPL == TIMEZONE_JDK) {
       defaultZone = new JavaTimeZone();
     } else {
       java.util.TimeZone temp = java.util.TimeZone.getDefault();
       defaultZone = getTimeZone(temp.getID());
     }
   }
   return (TimeZone) defaultZone.clone();
 }
コード例 #27
0
ファイル: ListJavaTimeZones.java プロジェクト: koem/Zimbra
 private static void printTZ(TimeZone tz) {
   String tzid = tz.getID();
   String gmtOffset = toGMTOffsetString(tz.getRawOffset());
   boolean isDst = tz.useDaylightTime();
   String clazz = tz.getClass().getSimpleName();
   String text =
       String.format(
           "%-20s (%s) - hasDST=%s (%s:%08x)",
           tzid, gmtOffset, (isDst ? "Y" : "N"), clazz, tz.hashCode());
   System.out.println(text);
 }
コード例 #28
0
ファイル: Datebox.java プロジェクト: adrgit/zk
 /** Sets the time zone that this date box belongs to, or null if
  * the default time zone is used.
  *
  * <p>The default time zone is determined by {@link TimeZones#getCurrent}.
  *
  * <p>Notice that if {@link #getDisplayedTimeZones} was called with
  * a non-empty list, the time zone must be one of it.
  * Otherwise (including <code>tzone</tt> is null),
  * the first timezone is selected.
  */
 public void setTimeZone(TimeZone tzone) {
   if (_tzone != tzone) {
     if (_dtzones != null) {
       _tzone = _dtzones.contains(tzone) ? tzone : _dtzones.get(0);
     } else {
       _tzone = tzone;
     }
     smartUpdate("timeZone", _tzone.getID());
     smartUpdate("_value", marshall(_value));
   }
 }
コード例 #29
0
 public Object getPropertyValue(Object id) {
   if (ID.equals(id)) {
     return timeZone.getID();
   } else if (DAYLIGHT.equals(id)) {
     return timeZone.inDaylightTime(new Date());
   } else if (NAME.equals(id)) {
     return timeZone.getDisplayName();
   } else {
     return null;
   }
 }
コード例 #30
0
  public void setClientTimeZone(TimeZone timeZone) {
    assert timeZone != null;

    identified = true;

    if (timeZone == this.timeZone) return;

    this.timeZone = timeZone;

    cookies.writeCookieValue(COOKIE_NAME, timeZone.getID());

    // Write to the Session, if it exists, in case the client doesn't support cookies.

    Session session = request.getSession(false);

    if (session != null) session.setAttribute(ATTRIBUTE_NAME, timeZone.getID());

    // Worst case: no session yet AND client doesn't support cookies. That means we'll likely
    // keep tracking the time zone (on the client) and updating (here on the server) until
    // a session gets created.
  }