@Test
  public void testToStringForTimeZone_fromApiDate() {
    Assert.assertEquals(
        stringDateTime1, DateTimes.toStringForTimeZone(apiDateTime1, TIME_ZONE_ID1));
    Assert.assertEquals(
        stringDateTime2, DateTimes.toStringForTimeZone(apiDateTime2, TIME_ZONE_ID2));
    Assert.assertEquals(
        stringDateTime3, DateTimes.toStringForTimeZone(apiDateTime3, TIME_ZONE_ID3));

    Assert.assertEquals(
        stringDateTime1,
        DateTimes.toStringForTimeZone(
            DateTimes.toDateTime(jodaDateTime1.withZone(DateTimeZone.forID(TIME_ZONE_ID2))),
            TIME_ZONE_ID1));
    Assert.assertEquals(
        stringDateTime2,
        DateTimes.toStringForTimeZone(
            DateTimes.toDateTime(jodaDateTime2.withZone(DateTimeZone.forID(TIME_ZONE_ID1))),
            TIME_ZONE_ID2));
    Assert.assertEquals(
        stringDateTime3,
        DateTimes.toStringForTimeZone(
            DateTimes.toDateTime(jodaDateTime3.withZone(DateTimeZone.forID(TIME_ZONE_ID1))),
            TIME_ZONE_ID3));
  }
 private void setDefaultTimeZone() {
   String dtzStr = pc.getProperties().getProperty("pig.datetime.default.tz");
   if (dtzStr != null && dtzStr.length() > 0) {
     currentDTZ = DateTimeZone.getDefault();
     DateTimeZone.setDefault(DateTimeZone.forID(dtzStr));
   }
 }
예제 #3
0
  private RegistrationChildForm getExpectedForm(String caseId) {
    ChildCase expectedChildCase = new ChildCase();
    expectedChildCase.setCaseId(caseId);

    Flw expectedFlw = new Flw();
    expectedFlw.setFlwId("89fda0284e008d2e0c980fb13fa0e5bb");

    RegistrationChildForm expectedChildForm = new RegistrationChildForm();
    expectedChildForm.setChildCase(expectedChildCase);
    expectedChildForm.setFlw(expectedFlw);
    expectedChildForm.setDateModified(
        new DateTime(2013, 3, 3, 10, 38, 52, 804, DateTimeZone.forOffsetHoursMinutes(5, 30))
            .toDate());
    expectedChildForm.setChildName("suraj");
    expectedChildForm.setBirthStatus("healthy");
    expectedChildForm.setInstanceId("ff2eb090-03a9-4f23-afed-cf6012784c55");
    expectedChildForm.setTimeStart(
        new DateTime(2013, 3, 3, 10, 31, 51, 45, DateTimeZone.forOffsetHoursMinutes(5, 30))
            .toDate());
    expectedChildForm.setTimeEnd(
        new DateTime(2013, 3, 3, 10, 38, 52, 804, DateTimeZone.forOffsetHoursMinutes(5, 30))
            .toDate());

    return expectedChildForm;
  }
예제 #4
0
 private NewForm expectedForm(MotherCase motherCase, Flw flw) {
   NewForm expectedForm = new NewForm();
   expectedForm.setDateModified(
       new DateTime(2012, 7, 21, 12, 2, 59, 923, DateTimeZone.forOffsetHoursMinutes(5, 30))
           .toDate());
   expectedForm.setFullName(
       "गायत्री देवी");
   expectedForm.setHusbandName(
       "दिनेश मुखिया");
   expectedForm.setHhNumber(165);
   expectedForm.setFamilyNumber(5);
   expectedForm.setDobKnown("no");
   expectedForm.setCaste("other");
   expectedForm.setAgeCalc(null);
   expectedForm.setInstanceId("e34707f8-80c8-4198-bf99-c11c90ba5c98");
   expectedForm.setMotherCase(motherCase);
   expectedForm.setFlw(flw);
   expectedForm.setTimeStart(
       new DateTime(2012, 7, 21, 11, 59, 31, 76, DateTimeZone.forOffsetHoursMinutes(5, 30))
           .toDate());
   expectedForm.setTimeEnd(
       new DateTime(2012, 7, 21, 12, 2, 59, 923, DateTimeZone.forOffsetHoursMinutes(5, 30))
           .toDate());
   return expectedForm;
 }
예제 #5
0
 public Rounding build() {
   Rounding timeZoneRounding;
   if (unit != null) {
     if (preTz.equals(DateTimeZone.UTC) && postTz.equals(DateTimeZone.UTC)) {
       timeZoneRounding = new UTCTimeZoneRoundingFloor(unit);
     } else if (preZoneAdjustLargeInterval
         || unit.field().getDurationField().getUnitMillis()
             < DateTimeConstants.MILLIS_PER_HOUR * 12) {
       timeZoneRounding = new TimeTimeZoneRoundingFloor(unit, preTz, postTz);
     } else {
       timeZoneRounding = new DayTimeZoneRoundingFloor(unit, preTz, postTz);
     }
   } else {
     if (preTz.equals(DateTimeZone.UTC) && postTz.equals(DateTimeZone.UTC)) {
       timeZoneRounding = new UTCIntervalTimeZoneRounding(interval);
     } else if (preZoneAdjustLargeInterval
         || interval < DateTimeConstants.MILLIS_PER_HOUR * 12) {
       timeZoneRounding = new TimeIntervalTimeZoneRounding(interval, preTz, postTz);
     } else {
       timeZoneRounding = new DayIntervalTimeZoneRounding(interval, preTz, postTz);
     }
   }
   if (preOffset != 0 || postOffset != 0) {
     timeZoneRounding = new PrePostRounding(timeZoneRounding, preOffset, postOffset);
   }
   if (factor != 1.0f) {
     timeZoneRounding = new FactorRounding(timeZoneRounding, factor);
   }
   return timeZoneRounding;
 }
  public DateTimeDatasetVersionFinder(FileSystem fs, Config config) {
    super(fs);
    Preconditions.checkArgument(
        config.hasPath(DATE_TIME_PATTERN_KEY),
        "Missing required property " + DATE_TIME_PATTERN_KEY);
    String pattern = config.getString(DATE_TIME_PATTERN_KEY);

    if (config.hasPath(OPTIONAL_GLOB_PATTERN_TIMEZONE_KEY)) {
      this.globPattern = new Path(config.getString(OPTIONAL_GLOB_PATTERN_TIMEZONE_KEY));
    } else {
      this.globPattern = new Path(pattern.replaceAll("[^/]+", "*"));
    }

    LOGGER.debug(
        String.format(
            "Setting timezone for patthern: %s. By default it is %s",
            pattern, DEFAULT_DATE_TIME_PATTERN_TIMEZONE));

    if (config.hasPath(DATE_TIME_PATTERN_TIMEZONE_KEY)) {
      this.formatter =
          DateTimeFormat.forPattern(pattern)
              .withZone(DateTimeZone.forID(config.getString(DATE_TIME_PATTERN_TIMEZONE_KEY)));
    } else {
      this.formatter =
          DateTimeFormat.forPattern(pattern)
              .withZone(DateTimeZone.forID(DEFAULT_DATE_TIME_PATTERN_TIMEZONE));
    }

    this.datePartitionPattern = pattern;
  }
 private static List<DateTimeZone> createZones() {
   final List<DateTimeZone> zones = new ArrayList<DateTimeZone>();
   for (final String zone : DateTimeZone.getAvailableIDs()) {
     zones.add(DateTimeZone.forID(zone));
   }
   return zones;
 }
  public HiveMetadata(
      HiveConnectorId connectorId,
      HiveMetastore metastore,
      HdfsEnvironment hdfsEnvironment,
      DateTimeZone timeZone,
      boolean allowDropTable,
      boolean allowRenameTable,
      boolean allowCorruptWritesForTesting,
      HiveStorageFormat hiveStorageFormat,
      TypeManager typeManager) {
    this.connectorId = checkNotNull(connectorId, "connectorId is null").toString();

    this.allowDropTable = allowDropTable;
    this.allowRenameTable = allowRenameTable;
    this.allowCorruptWritesForTesting = allowCorruptWritesForTesting;

    this.metastore = checkNotNull(metastore, "metastore is null");
    this.hdfsEnvironment = checkNotNull(hdfsEnvironment, "hdfsEnvironment is null");
    this.timeZone = checkNotNull(timeZone, "timeZone is null");
    this.hiveStorageFormat = hiveStorageFormat;
    this.typeManager = checkNotNull(typeManager, "typeManager is null");

    if (!allowCorruptWritesForTesting && !timeZone.equals(DateTimeZone.getDefault())) {
      log.warn(
          "Hive writes are disabled. "
              + "To write data to Hive, your JVM timezone must match the Hive storage timezone. "
              + "Add -Duser.timezone=%s to your JVM arguments",
          timeZone.getID());
    }
  }
예제 #9
0
  private static long getLongOrTimestamp(Object value, DateTimeZone hiveTimeZone) {
    if (value instanceof Date) {
      long storageTime = ((Date) value).getTime();
      // convert date from VM current time zone to UTC
      long utcMillis = storageTime + DateTimeZone.getDefault().getOffset(storageTime);
      return TimeUnit.MILLISECONDS.toDays(utcMillis);
    }
    if (value instanceof Timestamp) {
      // The Hive SerDe parses timestamps using the default time zone of
      // this JVM, but the data might have been written using a different
      // time zone. We need to convert it to the configured time zone.

      // the timestamp that Hive parsed using the JVM time zone
      long parsedJvmMillis = ((Timestamp) value).getTime();

      // remove the JVM time zone correction from the timestamp
      DateTimeZone jvmTimeZone = DateTimeZone.getDefault();
      long hiveMillis = jvmTimeZone.convertUTCToLocal(parsedJvmMillis);

      // convert to UTC using the real time zone for the underlying data
      long utcMillis = hiveTimeZone.convertLocalToUTC(hiveMillis, false);

      return utcMillis;
    }
    return ((Number) value).longValue();
  }
예제 #10
0
 @Override
 public long valueForKey(long time) {
   // now, time is still in local, move it to UTC (or the adjustLargeInterval flag is set)
   time = time - preTz.getOffset(time);
   // now apply post Tz
   time = time + postTz.getOffset(time);
   return time;
 }
예제 #11
0
 /**
  * Gets a debugging toString.
  *
  * @return a debugging string
  */
 public String toString() {
   String str = "BuddhistChronology";
   DateTimeZone zone = getZone();
   if (zone != null) {
     str = str + '[' + zone.getID() + ']';
   }
   return str;
 }
  @Override
  public void updateAnnotation(
      final UUID annotationId,
      final String annotationText,
      final String client,
      final long time,
      final DateTimeZone timezone)
      throws DataAccessException {

    // Create the transaction.
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setName("Updating an annotation.");

    try {
      // Begin the transaction.
      PlatformTransactionManager transactionManager =
          new DataSourceTransactionManager(getDataSource());
      TransactionStatus status = transactionManager.getTransaction(def);

      try {
        getJdbcTemplate()
            .update(
                SQL_UPDATE_ANNOTATION,
                time,
                timezone.getID(),
                client,
                annotationText,
                annotationId.toString());
      } catch (org.springframework.dao.DataAccessException e) {

        transactionManager.rollback(status);
        throw new DataAccessException(
            "Error executing SQL '"
                + SQL_UPDATE_ANNOTATION
                + "' with parameters: "
                + time
                + ", "
                + timezone.getID()
                + ", "
                + client
                + ", "
                + annotationText
                + ", "
                + annotationId.toString(),
            e);
      }

      // Commit the transaction.
      try {
        transactionManager.commit(status);
      } catch (TransactionException e) {
        transactionManager.rollback(status);
        throw new DataAccessException("Error while committing the transaction.", e);
      }
    } catch (TransactionException e) {
      throw new DataAccessException("Error while attempting to rollback the transaction.", e);
    }
  }
예제 #13
0
 public static Date getUtc() {
   SimpleDateFormat sdfAmerica = new SimpleDateFormat("dd-M-yyyy hh:mm:ss a");
   DateTime dt = new DateTime(new Date());
   DateTimeZone dtZone = DateTimeZone.forID("UTC");
   DateTime dtus = dt.withZone(dtZone);
   TimeZone tzInAmerica = dtZone.toTimeZone();
   Date dateInAmerica = dtus.toLocalDateTime().toDate();
   return dateInAmerica;
 }
예제 #14
0
 protected void setUp() throws Exception {
   DateTimeUtils.setCurrentMillisFixed(TEST_TIME_NOW);
   originalDateTimeZone = DateTimeZone.getDefault();
   originalTimeZone = TimeZone.getDefault();
   originalLocale = Locale.getDefault();
   DateTimeZone.setDefault(LONDON);
   TimeZone.setDefault(TimeZone.getTimeZone("Europe/London"));
   Locale.setDefault(Locale.UK);
 }
예제 #15
0
 private void verifyJvmTimeZone() {
   if (!allowCorruptWritesForTesting && !timeZone.equals(DateTimeZone.getDefault())) {
     throw new PrestoException(
         HIVE_TIMEZONE_MISMATCH,
         format(
             "To write Hive data, your JVM timezone must match the Hive storage timezone. Add -Duser.timezone=%s to your JVM arguments.",
             timeZone.getID()));
   }
 }
예제 #16
0
 @Override
 public long valueForKey(long key) {
   long time = Rounding.Interval.roundValue(key, interval);
   // now, time is still in local, move it to UTC
   time = time - preTz.getOffset(time);
   // now apply post Tz
   time = time + postTz.getOffset(time);
   return time;
 }
예제 #17
0
 public void test_timeZoneFromString() throws Exception {
   Long nn = System.currentTimeMillis();
   String tz = "Europe/Berlin";
   DateTimeZone tzz = DateTimeZone.forID(tz);
   DateTime inberl = DateTimeOperations.convert(nn, DateTimeZone.forID(tz));
   Assert.assertEquals(inberl, DateTimeOperations.convert(nn, tzz));
   Assert.assertEquals("Europe/Berlin", tzz.getID());
   Assert.assertEquals("Europe/Moscow", DateTimeZone.forID("Europe/Moscow").getID());
 }
  @Test(groups = "fast")
  public void testCalculateBCDWithSubscriptionDateNotInUTC() throws Exception {
    // Test to verify the computations don't rely implicitly on UTC
    final DateTimeZone accountTimeZone = DateTimeZone.forID("Asia/Tokyo");
    final DateTime startDate = new DateTime("2012-07-16T21:17:03.000Z", DateTimeZone.forID("HST"));
    final int bcdLocal = 17;

    verifyBCDCalculation(accountTimeZone, startDate, bcdLocal);
  }
예제 #19
0
 public void test_inLocale() throws Exception {
   Assert.assertEquals(
       "Heure d'Europe centrale",
       DateTimeZone.forID("Europe/Prague")
           .getName(
               DateTimeOperations.convert(
                   new DateTime(2008, 1, 1, 12, 0, 0, 0, DateTimeZone.forID("Europe/Prague"))),
               Locale.FRENCH));
 }
  public void testTimeUnitRoundingDST() {
    Rounding tzRounding;
    // testing savings to non savings switch
    DateTimeZone cet = DateTimeZone.forID("CET");
    tzRounding = Rounding.builder(DateTimeUnit.HOUR_OF_DAY).timeZone(cet).build();
    assertThat(
        tzRounding.round(time("2014-10-26T01:01:01", cet)),
        isDate(time("2014-10-26T01:00:00+02:00"), cet));
    assertThat(
        tzRounding.nextRoundingValue(time("2014-10-26T01:00:00", cet)),
        isDate(time("2014-10-26T02:00:00+02:00"), cet));
    assertThat(
        tzRounding.nextRoundingValue(time("2014-10-26T02:00:00", cet)),
        isDate(time("2014-10-26T02:00:00+01:00"), cet));

    // testing non savings to savings switch
    tzRounding = Rounding.builder(DateTimeUnit.HOUR_OF_DAY).timeZone(cet).build();
    assertThat(
        tzRounding.round(time("2014-03-30T01:01:01", cet)),
        isDate(time("2014-03-30T01:00:00+01:00"), cet));
    assertThat(
        tzRounding.nextRoundingValue(time("2014-03-30T01:00:00", cet)),
        isDate(time("2014-03-30T03:00:00", cet), cet));
    assertThat(
        tzRounding.nextRoundingValue(time("2014-03-30T03:00:00", cet)),
        isDate(time("2014-03-30T04:00:00", cet), cet));

    // testing non savings to savings switch (America/Chicago)
    DateTimeZone chg = DateTimeZone.forID("America/Chicago");
    Rounding tzRounding_utc =
        Rounding.builder(DateTimeUnit.HOUR_OF_DAY).timeZone(DateTimeZone.UTC).build();
    assertThat(
        tzRounding.round(time("2014-03-09T03:01:01", chg)),
        isDate(time("2014-03-09T03:00:00", chg), chg));

    Rounding tzRounding_chg = Rounding.builder(DateTimeUnit.HOUR_OF_DAY).timeZone(chg).build();
    assertThat(
        tzRounding_chg.round(time("2014-03-09T03:01:01", chg)),
        isDate(time("2014-03-09T03:00:00", chg), chg));

    // testing savings to non savings switch 2013 (America/Chicago)
    assertThat(
        tzRounding_utc.round(time("2013-11-03T06:01:01", chg)),
        isDate(time("2013-11-03T06:00:00", chg), chg));
    assertThat(
        tzRounding_chg.round(time("2013-11-03T06:01:01", chg)),
        isDate(time("2013-11-03T06:00:00", chg), chg));

    // testing savings to non savings switch 2014 (America/Chicago)
    assertThat(
        tzRounding_utc.round(time("2014-11-02T06:01:01", chg)),
        isDate(time("2014-11-02T06:00:00", chg), chg));
    assertThat(
        tzRounding_chg.round(time("2014-11-02T06:01:01", chg)),
        isDate(time("2014-11-02T06:00:00", chg), chg));
  }
예제 #21
0
    private RubyTime buildTime(
        VirtualFrame frame,
        RubyClass timeClass,
        int sec,
        int min,
        int hour,
        int mday,
        int month,
        int year,
        int nsec,
        int isdst,
        boolean fromutc,
        Object utcoffset) {
      CompilerDirectives.transferToInterpreter();

      if (sec < 0
          || sec > 59
          || min < 0
          || min > 59
          || hour < 0
          || hour > 23
          || mday < 1
          || mday > 31
          || month < 1
          || month > 12) {
        throw new RaiseException(getContext().getCoreLibrary().argumentErrorOutOfRange(this));
      }

      final DateTimeZone zone;
      if (fromutc) {
        zone = DateTimeZone.UTC;
      } else if (utcoffset == nil()) {
        String tz = readTimeZoneNode.executeRubyString(frame).toString();
        zone = org.jruby.RubyTime.getTimeZoneFromTZString(getContext().getRuntime(), tz);
      } else if (utcoffset instanceof Integer) {
        zone = DateTimeZone.forOffsetMillis(((int) utcoffset) * 1_000);
      } else if (utcoffset instanceof Long) {
        zone = DateTimeZone.forOffsetMillis((int) ((long) utcoffset) * 1_000);
      } else if (utcoffset instanceof RubyBasicObject) {
        final int millis = cast(ruby(frame, "(offset * 1000).to_i", "offset", utcoffset));
        zone = DateTimeZone.forOffsetMillis(millis);
      } else {
        throw new UnsupportedOperationException(
            String.format("%s %s %s %s", isdst, fromutc, utcoffset, utcoffset.getClass()));
      }

      if (isdst == -1) {
        final DateTime dateTime =
            new DateTime(year, month, mday, hour, min, sec, nsec / 1_000_000, zone);
        return new RubyTime(timeClass, dateTime, utcoffset);
      } else {
        throw new UnsupportedOperationException(
            String.format("%s %s %s %s", isdst, fromutc, utcoffset, utcoffset.getClass()));
      }
    }
예제 #22
0
  /**
   * Extract time-zone information from a zoneinfo (Olson database) ID and saves them in the
   * TimeZoneHelper fields.
   *
   * @param id the time zone ID according to the zoneinfo (Olson) database
   * @param from the start of the relevant time interval for the generation of transitions (an
   *     istant expressed as a long)
   * @param to the end of the relevant time interval for the generation of transitions (an istant
   *     expressed as a long)
   */
  protected void processID(String id, long from, long to) {

    DateTimeZone tz = DateTimeZone.forID(id);
    if (name == null) { // The name could have been set already using TZID
      // and in this case it is important not to change it
      name = id; // The Olson ID is perfect as a unique name
    }
    basicOffset = tz.getStandardOffset(from);
    transitions.clear();

    if (!tz.isFixed()) {

      long oldFrom = from;
      from = fixFrom(tz, basicOffset, oldFrom);

      // @todo Consider case when to go beyond last transition (cycle
      // could become endless)
      while (tz.getStandardOffset(to) != tz.getOffset(to)) {
        to = tz.nextTransition(to);
      }

      while ((from <= to) && (oldFrom != from)) {
        transitions.add(new TimeZoneTransition(tz.getOffset(from), from, id));
        oldFrom = from;
        from = tz.nextTransition(oldFrom);
      }
    }
  }
예제 #23
0
  public static void init() {
    InputStream input = null;

    try {
      File file = new File(PROPERTYFILE);
      input = new FileInputStream(file);
    } catch (Exception e) {
      LOGGER.info("" + e);
      input = null;
    }

    try {
      if (input == null) {
        input = Environment.class.getClassLoader().getResourceAsStream(PROPERTYFILE);
      }
      if (input == null) {
        throw new ResourceNotFoundException(PROPERTYFILE);
      }
      props.load(input);
      Enumeration<?> e = props.propertyNames();
      while (e.hasMoreElements()) {
        String key = (String) e.nextElement();
        String value = props.getProperty(key);
        config.put(key, value);
      }
      String language = getProperty("locale.language", Locale.getDefault().getLanguage());
      String country = getProperty("locale.country", Locale.getDefault().getCountry());
      locale = new Locale(language, country);

      String timeZoneId = getProperty("datetime.timeZone");
      timeZone = (timeZoneId == null) ? DateTimeZone.getDefault() : DateTimeZone.forID(timeZoneId);

      appHome = getProperty("app.home", APPHOME);
      if (appHome.startsWith("~")) {
        appHome = appHome.replaceFirst("~", System.getProperty("user.home"));
      }

      new File(getDataFolder()).mkdirs();
      new File(getRptFolder()).mkdirs();
      new File(getTmpFolder()).mkdirs();
      new File(getCacheFolder()).mkdirs();
      new File(getLogFolder()).mkdirs();

    } catch (IOException e) {
      throw new ResourceIOException(PROPERTYFILE, e);
    } finally {
      if (input != null) {
        try {
          input.close();
        } catch (IOException e) {
          throw new ResourceIOException(PROPERTYFILE, e);
        }
      }
    }
  }
예제 #24
0
 public void test_allZones() throws Exception {
   int count = 0;
   for (String id : ((Set<String>) DateTimeZone.getAvailableIDs())) {
     if (id.startsWith("Europe/P")) {
       // note: sometimes id != timezone(id).id
       count++;
     }
   }
   Assert.assertTrue(count >= 3);
   Assert.assertTrue(((Set<String>) DateTimeZone.getAvailableIDs()).contains("Europe/Moscow"));
 }
 /**
  * @param instant instant from 1970-01-01T00:00:00 local time
  * @return instant from 1970-01-01T00:00:00Z
  */
 private long localToUTC(long instant) {
   DateTimeZone zone = getZone();
   int offset = zone.getOffsetFromLocal(instant);
   instant -= offset;
   if (offset != zone.getOffset(instant)) {
     throw new IllegalArgumentException(
         "Illegal instant due to time zone offset transition: "
             + DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSS").print(new Instant(instant)));
   }
   return instant;
 }
 public long addWrapField(long instant, int value) {
   if (iTimeField) {
     int offset = getOffsetToAdd(instant);
     long localInstant = iField.addWrapField(instant + offset, value);
     return localInstant - offset;
   } else {
     long localInstant = iZone.convertUTCToLocal(instant);
     localInstant = iField.addWrapField(localInstant, value);
     return iZone.convertLocalToUTC(localInstant, false, instant);
   }
 }
 public long roundCeiling(long instant) {
   if (iTimeField) {
     int offset = getOffsetToAdd(instant);
     instant = iField.roundCeiling(instant + offset);
     return instant - offset;
   } else {
     long localInstant = iZone.convertUTCToLocal(instant);
     localInstant = iField.roundCeiling(localInstant);
     return iZone.convertLocalToUTC(localInstant, false, instant);
   }
 }
 @Override
 public void onReceive(Context context, Intent intent) {
   String action = intent.getAction();
   if (action.equals(Intent.ACTION_LOCALE_CHANGED)
       || action.equals(Intent.ACTION_TIME_CHANGED)
       || action.equals(Intent.ACTION_DATE_CHANGED)
       || action.equals(Intent.ACTION_TIMEZONE_CHANGED)) {
     DateTimeZone.setDefault(DateTimeZone.forID(TimeZone.getDefault().getID()));
     EventAppWidgetProvider.updateAllWidgets(context);
   }
   EventAppWidgetProvider.updateEventList(context);
 }
 private DateTimeZone getTimeZone(HttpServletRequest request) {
   Integer millisOffset = getMillisOffset(request);
   if (millisOffset != null) {
     try {
       return DateTimeZone.forOffsetMillis(millisOffset);
     } catch (IllegalArgumentException e) {
       return DateTimeZone.getDefault();
     }
   } else {
     return DateTimeZone.getDefault();
   }
 }
  @Override
  public Timestamp toNonNullValue(DateTime value) {

    DateTimeZone currentDatabaseZone =
        databaseZone == null ? ZoneHelper.getDefault() : databaseZone;

    int adjustment =
        TimeZone.getDefault().getOffset(value.getMillis()) - currentDatabaseZone.getOffset(null);

    final Timestamp timestamp = new Timestamp(value.getMillis() - adjustment);
    return timestamp;
  }