Package java.util

Examples of java.util.TimeZone$DisplayNames


    /**
     * Tests this class.
     */
    public static void main(final String[] args) throws Exception {
        final TimeZone tz = TimeZone.getTimeZone("UTC");
        final Calendar calendar = Calendar.getInstance(tz);
        calendar.clear();
        calendar.set(1970, 0, 1);
        new TimeScaleUnit(SECOND, calendar.getTime());
    }
View Full Code Here


  final public Calendar zoneExpr(Calendar calendar) throws ParseException {
    int         sign = 1;
    int         zoneHour;
    int         zoneMinute = 0;
    Token       token;
    TimeZone    timeZone;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case PLUS:
    case MINUS:
    case UINT:
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case PLUS:
      case MINUS:
        sign = sign();
        break;
      default:
        jj_la1[32] = jj_gen;
        ;
      }
      zoneHour = unsignedInteger();
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case COLON:
      case UINT:
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case COLON:
          jj_consume_token(COLON);
          break;
        default:
          jj_la1[33] = jj_gen;
          ;
        }
        zoneMinute = unsignedInteger();
        break;
      default:
        jj_la1[34] = jj_gen;
        ;
      }
                if (zoneHour >= 100)
                {
                    zoneMinute += zoneHour % 100;
                    zoneHour /= 100;
                }
                if (zoneHour > 23 || zoneMinute > 59)
                {
                    {if (true) throw new ParseException("invalid time-zone in timestamp");}
                }
                timeZone = TimeZone.getTimeZone("UTC");
                timeZone.setRawOffset(sign*(zoneHour*60 + zoneMinute)*60*1000);
      break;
    case NAME:
      token = jj_consume_token(NAME);
                timeZone = TimeZone.getTimeZone(token.image);
      break;
View Full Code Here

    public static String formatDate(String dateTime, String pattern)
    {
        final String yearSymbols = "Gy";
        final String monthSymbols = "M";
        final String daySymbols = "dDEFwW";
        TimeZone timeZone;
        String zone;

        // Get the timezone information if it was supplied and modify the
        // dateTime so that SimpleDateFormat will understand it.
        if (dateTime.endsWith("Z") || dateTime.endsWith("z"))
View Full Code Here

      }
      String[][] zoneStrings = formatData.getZoneStringsWrapper();
      buffer.append(zoneStrings[zoneIndex][index]);
        }
    } else {
        TimeZone tz = calendar.getTimeZone();
        boolean daylight = (calendar.get(Calendar.DST_OFFSET) != 0);
        int tzstyle = (count < 4 ? TimeZone.SHORT : TimeZone.LONG);
        buffer.append(tz.getDisplayName(daylight, tzstyle, formatData.locale));
    }
      }
            break;

        case 18: // 'Z' - ZONE_OFFSET ("-/+hhmm" form)
View Full Code Here

  // If the deserialized object has a SimpleTimeZone, try
  // to replace it with a ZoneInfo equivalent in order to
  // be compatible with the SimpleTimeZone-based
  // implementation as much as possible.
  TimeZone tz = getTimeZone();
  if (tz instanceof SimpleTimeZone) {
      String id = tz.getID();
      TimeZone zi = TimeZone.getTimeZone(id);
      if (zi != null && zi.hasSameRules(tz) && zi.getID().equals(id)) {
    setTimeZone(zi);
      }
  }
    }
View Full Code Here

      return "NOW";
    }
    else {
      long date = sendTime.getTime();
     
      TimeZone tz = TimeZone.getTimeZone(timeZoneID);
//      tz.setStartRule(Calendar.MARCH, -1, Calendar.SUNDAY,  2*60*60*1000);
//      tz.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY,  2*60*60*1000);

      date -= tz.getRawOffset();
      if (tz.inDaylightTime(sendTime)) {
        date -= 3600 * 1000;
      }

      return new SimpleDateFormat("yyyyMMddHHmm").format(new Date(date));
    }
View Full Code Here

  public static String getDateTime()
  {
    Calendar cal = Calendar.getInstance();
    SimpleDateFormat dateTimeFormat = new SimpleDateFormat(DATETIMEFORMAT);
    TimeZone timeZone = cal.getTimeZone();

    return dateTimeFormat.format(new Date(cal.getTimeInMillis()
        - timeZone.getOffset(cal.getTimeInMillis())));
  }
View Full Code Here

    public void testLocalTime() throws ParseException {
        Date dsum = DF.parse("AD 2010-05-09 20:00:00:0 UTC");
        Date dwin = DF.parse("AD 2010-01-01 20:00:00:0 UTC");
       
        TimeZone tzRome = TimeZone.getTimeZone("Europe/Rome");
        if (tzRome.getOffset(0) == 0) {
            throw new RuntimeException(
                    "Can't get time zone for Europe/Rome!");
        }
        assertEquals(
                "2010-05-09T22:00:00+02",
                dateToISO8601DateTimeString(dsum, tzRome));
        assertEquals(
                "2010-01-01T21:00:00+01",
                dateToISO8601DateTimeString(dwin, tzRome));
        assertEquals(
                "2010-05-09",
                dateToISO8601DateString(dsum, tzRome));
        assertEquals(
                "2010-01-01",
                dateToISO8601DateString(dwin, tzRome));
        assertEquals(
                "22:00:00+02",
                dateToISO8601TimeString(dsum, tzRome));
        assertEquals(
                "21:00:00+01",
                dateToISO8601TimeString(dwin, tzRome));
       
        TimeZone tzNY = TimeZone.getTimeZone("America/New_York");
        if (tzNY.getOffset(0) == 0) {
            throw new RuntimeException(
                    "Can't get time zone for America/New_York!");
        }
        assertEquals(
                "2010-05-09T16:00:00-04",
                dateToISO8601DateTimeString(dsum, tzNY));
        assertEquals(
                "2010-01-01T15:00:00-05",
                dateToISO8601DateTimeString(dwin, tzNY));
        assertEquals(
                "2010-05-09",
                dateToISO8601DateString(dsum, tzNY));
        assertEquals(
                "2010-01-01",
                dateToISO8601DateString(dwin, tzNY));
        assertEquals(
                "16:00:00-04",
                dateToISO8601TimeString(dsum, tzNY));
        assertEquals(
                "15:00:00-05",
                dateToISO8601TimeString(dwin, tzNY));
       
        TimeZone tzFixed = TimeZone.getTimeZone("GMT+02:30");
        assertEquals(
                "2010-05-09T22:30:00+02:30",
                dateToISO8601DateTimeString(dsum, tzFixed));
        assertEquals(
                "2010-01-01T22:30:00+02:30",
View Full Code Here

        tf.setTimeZone(DateUtil.UTC);
        assertEquals("00:00:00", tf.format(t));
        assertEquals("00:00:00",
                dateToISO8601UTCTimeString(t, false));
       
        TimeZone gmt1 = DateUtil.getTimeZone("GMT+01");
        tf.setTimeZone(gmt1);
        assertEquals("01:00:00", tf.format(t));
        assertEquals("01:00:00+01",
                dateToISO8601TimeString(t, gmt1));
    }
View Full Code Here

        if (jsonLocaleCode != null) {
          datasource.setLocale(jsonLocaleCode);
        }
      }
     
      TimeZone jsonTimezone = (TimeZone) getParameterValue(JsonQueryExecuterFactory.JSON_TIME_ZONE, true);
      if (jsonTimezone != null) {
        datasource.setTimeZone(jsonTimezone);
      } else {
        String jsonTimezoneId = getStringParameterOrProperty(JsonQueryExecuterFactory.JSON_TIMEZONE_ID);
        if (jsonTimezoneId != null) {
View Full Code Here

TOP

Related Classes of java.util.TimeZone$DisplayNames

Copyright © 2018 www.massapicom. 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.