Package java.util

Examples of java.util.TimeZone.inDaylightTime()


        } else {
            sb.append("" + seconds);
        }

        double offset = cal.get(Calendar.ZONE_OFFSET);
        if (tz.inDaylightTime(inputDate)) {
            offset += (1.0 * tz.getDSTSavings()); // add the timezone's DST
                                                  // value (typically 1 hour
                                                  // expressed in milliseconds)
        }

View Full Code Here


  /**
   * Shows the current time zone (based on the current time) short name
   */
  private static String getShortTZName() {
    TimeZone tz = TimeZone.getDefault();
    return tz.getDisplayName(tz.inDaylightTime(new Date()), TimeZone.SHORT);
  }
 
  /**
   * Converts a unix timestamp in UTC to one that is relative to the local timezone
   */
 
View Full Code Here

                }
            }
            TimeZone tz = cal.getTimeZone();
            // JDK 1.4: int offset = tz.getOffset(cal.getTimeInMillis());
            int offset = cal.get(Calendar.ZONE_OFFSET);
            if (tz.inDaylightTime(cal.getTime())) {
                offset += cal.get(Calendar.DST_OFFSET);
            }
            if (offset == 0) {
                pBuffer.append('Z');
            } else {
View Full Code Here

    else {
      // Determine the hour offset. Add an hour if daylight savings
      // is in effect.
      long tzOffsetMS = tz.getRawOffset();
      long tzOffsetHH = tzOffsetMS / MS_IN_HOUR;
      if (tz.inDaylightTime(inputDate)) {
        tzOffsetHH = tzOffsetHH + 1;
      }
      String hourString = String.valueOf(Math.abs(tzOffsetHH));
      if (hourString.length() == 1) {
        hourString = "0" + hourString;
View Full Code Here

        Date date = cal.getTime() ;
        TimeZone z = cal.getTimeZone() ;
        int tzOff = z.getRawOffset() ;
        int tz = tzOff ;

        if ( z.inDaylightTime(date) )
        {
            int tzDst = z.getDSTSavings() ;
            tz = tz + tzDst ;
        }
       
View Full Code Here

        }
        if (parseTimezone) {
            TimeZone tz = cal.getTimeZone();
            // JDK 1.4: int offset = tz.getOffset(cal.getTimeInMillis());
            int offset = cal.get(Calendar.ZONE_OFFSET);
            if (tz.inDaylightTime(cal.getTime())) {
                offset += cal.get(Calendar.DST_OFFSET);
            }
            if (offset == 0) {
                pBuffer.append('Z');
            } else {
View Full Code Here

    else {
      // Determine the hour offset. Add an hour if daylight savings
      // is in effect.
      long tzOffsetMS = tz.getRawOffset();
      long tzOffsetHH = tzOffsetMS / MS_IN_HOUR;
      if (tz.inDaylightTime(inputDate)) {
        tzOffsetHH = tzOffsetHH + 1;
      }
      String hourString = String.valueOf(Math.abs(tzOffsetHH));
      if (hourString.length() == 1) {
        hourString = "0" + hourString;
View Full Code Here

    public static String getTimeZoneName(String zoneID, Locale locale) {
        TimeZone zone = TimeZone.getTimeZone(zoneID);
        StringBuffer buf = new StringBuffer();
        // Add in the GMT part to the name. First, figure out the offset.
        int offset = zone.getRawOffset();
        if (zone.inDaylightTime(new Date()) && zone.useDaylightTime()) {
            offset += (int)JiveConstants.HOUR;
        }

        buf.append("(");
        if (offset < 0) {
View Full Code Here

            java.util.Iterator it = zoneTree.iterator();
            while (it.hasNext())
            {
                StringBuffer sb = new StringBuffer();
                TimeZone zone = (TimeZone)it.next();
                sb.append(zone.getDisplayName(zone.inDaylightTime(today), TimeZone.SHORT));
                sb.append(" - ");
                sb.append(zone.getID());
                timeZones.add(new LabelValueBean(
                   sb.toString(),
                   zone.getID()));
View Full Code Here

     * @param self a Date
     * @return the DST offset as a Duration.
     */
    public static Duration getDaylightSavingsOffset(Date self) {
        TimeZone timeZone = getTimeZone(self);
        int millis = (timeZone.useDaylightTime() && timeZone.inDaylightTime(self))
                ? timeZone.getDSTSavings() : 0;
        return new TimeDuration(0, 0, 0, millis);
    }

    public static Duration getDaylightSavingsOffset(BaseDuration self) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.