public String getUTCStart() { return dstart.toString(); }
public String getUTCEnd() { return dend.toString(); }
public String getUTCEnd() { return dend.toString(); }
public String getUTCStart() { return dstart.toString(); }
public String getUTCStart() { return dstart.toString(); }
public String getUTCEnd() { return dend.toString(); }
public String getUTCEnd() { return dend.toString(); }
public String getUTCStart() { return dstart.toString(); }
private String fromDateToStringNoTimezone(Date date) { if(date==null) { return null; } if(date instanceof DateTime) { DateTime dt = (DateTime) date; // If DateTime has a timezone, then convert to UTC before // serializing as String. if(dt.getTimeZone()!=null) { // clone instance first to prevent changes to original instance DateTime copy = new DateTime(dt); copy.setUtc(true); return copy.toString(); } else { return dt.toString(); } } else { return date.toString(); } }
private String fromDateToStringNoTimezone(Date date) { if(date==null) { return null; } if(date instanceof DateTime) { DateTime dt = (DateTime) date; // If DateTime has a timezone, then convert to UTC before // serializing as String. if(dt.getTimeZone()!=null) { // clone instance first to prevent changes to original instance DateTime copy = new DateTime(dt); copy.setUtc(true); return copy.toString(); } else { return dt.toString(); } } else { return date.toString(); } }
/** For date only values and floating convert to local UTC. For UTC just return * the value. For non-floating convert. * * @param dt * @param tzs * @return string UTC value * @throws Throwable */ public static String getUTC(final DateDatetimePropertyType dt, final TzGetter tzs) throws Throwable { DtTzid dtz = getDtTzid(dt); if ((dtz.dt.length() == 18) && (dtz.dt.charAt(17) == 'Z')) { return dtz.dt; } TimeZone tz = null; if (dtz.tzid != null) { tz = tzs.getTz(dtz.tzid); } DateTime dtim = new DateTime(dtz.dt, tz); dtim.setUtc(true); return dtim.toString(); }
/** * @throws ParseException */ public void testSetValue() throws ParseException { trigger.setValue(new DateTime(new Date(0).getTime()).toString()); log.info(new DateTime(new Date(0).getTime()).toString()); log.info(trigger.toString()); // trigger.setValue(DurationFormat.getInstance().format(5000)); trigger.setValue(java.time.Duration.ofSeconds(5).toString()); // log.info(DurationFormat.getInstance().format(5000)); log.info(java.time.Duration.ofSeconds(5).toString()); log.info(trigger.toString()); }
/** * Return a Date instance that represents the day that a point in * time translates into local time given a timezone. * @param utcDateTime point in time * @param tz timezone The timezone. * @return The date. */ public static Date normalizeUTCDateTimeToDate(DateTime utcDateTime, TimeZone tz) { if(!utcDateTime.isUtc()) { throw new IllegalArgumentException("datetime must be utc"); } // if no timezone, use default if (tz == null) { return new Date(utcDateTime); } DateTime copy = (DateTime) Dates.getInstance(utcDateTime, utcDateTime); copy.setTimeZone(tz); try { return new Date(copy.toString().substring(0, 8)); } catch (ParseException e) { throw new CosmoParseException("error creating Date instance", e); } }
/** * */ public void testToString() { assertNotNull("Null input date", dateTime); assertEquals("Incorrect string representation", expectedToString, dateTime.toString()); }
/** * Test equality of DateTime instances created using different constructors. * * @throws ParseException */ public void testDateTimeEquals() throws ParseException { // change default tz to non-UTC timezone. java.util.TimeZone originalTzDefault = java.util.TimeZone.getDefault(); java.util.TimeZone.setDefault(java.util.TimeZone.getTimeZone("Australia/Melbourne")); DateTime date1 = new DateTime("20050101T093000"); Calendar calendar = Calendar.getInstance(); //TimeZone.getTimeZone("Etc/UTC")); calendar.clear(); calendar.set(2005, 0, 1, 9, 30, 00); calendar.set(Calendar.MILLISECOND, 1); DateTime date2 = new DateTime(calendar.getTime()); assertEquals(date1.hashCode(), date2.hashCode()); assertEquals(date1.toString(), date2.toString()); assertEquals(date1, date2); java.util.TimeZone.setDefault(originalTzDefault); }
public void testZuluToLocal() throws Exception { DateTime d = new DateTime(zuluDateTimeStr); d.setTimeZone(timezone); assertEquals(expectedLocalDateTimeStr, d.toString()); }
/** * @return * @throws ParseException */ public static TestSuite suite() throws ParseException { TestSuite suite = new TestSuite(); suite.addTest(new DateListTest(new DateList(), 0)); suite.addTest(new DateListTest(new Date().toString(), Value.DATE, 1)); suite.addTest(new DateListTest(new DateTime().toString(), Value.DATE_TIME, 1)); suite.addTest(new DateListTest(new DateTime(123).toString() + "," + new DateTime(999).toString(), Value.DATE_TIME, 2)); return suite; } }
/** * Unit tests for value/timezone constructor. */ public void testDtStartStringTimezone() throws ParseException { String value = new DateTime().toString(); DtStart dtStart = new DtStart(value, timezone); assertEquals(timezone, dtStart.getTimeZone()); assertEquals(value, dtStart.getValue()); }
public void testRelaxed() throws Exception { try { new DateTime(badlyFormated); fail("expected ParseException"); } catch (ParseException pe) { } try { CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true); DateTime dt = new DateTime(badlyFormated); assertEquals(this.expectedToString, dt.toString()); } catch (ParseException pe) { fail("exception not expected with relaxed parsing is used"); } finally { CompatibilityHints.clearHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING); } }
/** * Unit tests for timezone constructor. */ public void testDtStartTimezone() throws ParseException { DtStart dtStart = new DtStart(timezone); dtStart.setValue(new DateTime().toString()); assertEquals(timezone, dtStart.getTimeZone()); // initialising with DATE value should reset timezone.. dtStart.setDate(new Date()); assertNull(dtStart.getTimeZone()); }