@Override public DateMidnight deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { // We'll accept either long (timestamp) or array: if (jp.isExpectedStartArrayToken()) { jp.nextToken(); // VALUE_NUMBER_INT int year = jp.getIntValue(); jp.nextToken(); // VALUE_NUMBER_INT int month = jp.getIntValue(); jp.nextToken(); // VALUE_NUMBER_INT int day = jp.getIntValue(); if (jp.nextToken() != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(jp, JsonToken.END_ARRAY, "after DateMidnight ints"); } return new DateMidnight(year, month, day); } switch (jp.getCurrentToken()) { case VALUE_NUMBER_INT: return new DateMidnight(jp.getLongValue()); case VALUE_STRING: DateTime local = parseLocal(jp); if (local == null) { return null; } return local.toDateMidnight(); } throw ctxt.wrongTokenException( jp, JsonToken.START_ARRAY, "expected JSON Array, Number or String"); }
// ----------------------------------------------------------------------- public void testConstructor_RI_RI1() throws Throwable { DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0); DateTime dt2 = new DateTime(2005, 7, 10, 1, 1, 1, 1); Interval test = new Interval(dt1, dt2); assertEquals(dt1.getMillis(), test.getStartMillis()); assertEquals(dt2.getMillis(), test.getEndMillis()); }
public void testConstructor_Object5() throws Throwable { IntervalConverter oldConv = ConverterManager.getInstance().getIntervalConverter(""); IntervalConverter conv = new IntervalConverter() { public boolean isReadableInterval(Object object, Chronology chrono) { return false; } public void setInto(ReadWritableInterval interval, Object object, Chronology chrono) { interval.setChronology(chrono); interval.setInterval(1234L, 5678L); } public Class<?> getSupportedType() { return String.class; } }; try { ConverterManager.getInstance().addIntervalConverter(conv); DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0); DateTime dt2 = new DateTime(2005, 7, 10, 1, 1, 1, 1); Interval test = new Interval(dt1.toString() + '/' + dt2.toString()); assertEquals(1234L, test.getStartMillis()); assertEquals(5678L, test.getEndMillis()); } finally { ConverterManager.getInstance().addIntervalConverter(oldConv); } }
public static void main(String argv[]) { RTConfig.setCommandLineArgs(argv); long now = DateTime.getCurrentTimeSec(); long sts = now - DateTime.DaySeconds(3); long ets = now; GoogleChartTemperature gct = new GoogleChartTemperature(); try { gct.setSize(700, 400); gct.setTitle(Color.black, 16, "Temperature"); gct.setTemperatureRange(1, F2C(0.0), F2C(130.0), 10); gct.setDateRange(new DateTime(sts), new DateTime(ets), 8); gct.setDateFormat("MM/dd"); gct.setTimeFormat("HH:mm:ss"); int setCount = 3; int tempCount = 15; gct._addRandomSampleData(setCount, tempCount); System.out.println(gct.toString()); } catch (Throwable th) { Print.logException("Error", th); System.exit(1); } }
public void testConstructor_long_long2() throws Throwable { DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0); Interval test = new Interval(dt1.getMillis(), dt1.getMillis()); assertEquals(dt1.getMillis(), test.getStartMillis()); assertEquals(dt1.getMillis(), test.getEndMillis()); assertEquals(ISOChronology.getInstance(), test.getChronology()); }
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); DateTime calendar = new DateTime(shell, SWT.CALENDAR); calendar.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { System.out.println("calendar date changed"); } }); DateTime time = new DateTime(shell, SWT.TIME); time.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { System.out.println("time changed"); } }); shell.pack(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
public void testToDateTime_nullRI() { LocalTime base = new LocalTime(1, 2, 3, 4); DateTimeUtils.setCurrentMillisFixed(TEST_TIME2); DateTime test = base.toDateTime((ReadableInstant) null); check(base, 1, 2, 3, 4); assertEquals("1970-01-02T01:02:03.004+01:00", test.toString()); }
public void testConstructor_RI_RI_chronoStart() throws Throwable { DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0, GJChronology.getInstance()); DateTime dt2 = new DateTime(2005, 7, 10, 1, 1, 1, 1); Interval test = new Interval(dt1, dt2); assertEquals(dt1.getMillis(), test.getStartMillis()); assertEquals(dt2.getMillis(), test.getEndMillis()); assertEquals(GJChronology.getInstance(), test.getChronology()); }
private DtStart getStartDateProperty(Date startDate) { DateTime date = convertRaplaLocaleToUTC(startDate); TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry(); net.fortuna.ical4j.model.TimeZone tz = registry.getTimeZone(timeZone.getID()); date.setTimeZone(tz); return new DtStart(date); }
public static DateTime fromString(java.lang.String value, java.lang.String namespaceURI) { DateTime returnValue = new DateTime(); returnValue.setDateTime( org.apache.axis2.databinding.utils.ConverterUtil.convertToDateTime(value)); return returnValue; }
public void testConstructor_RI_RI_zones() throws Throwable { DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0, LONDON); DateTime dt2 = new DateTime(2005, 7, 10, 1, 1, 1, 1, PARIS); Interval test = new Interval(dt1, dt2); assertEquals(dt1.getMillis(), test.getStartMillis()); assertEquals(dt2.getMillis(), test.getEndMillis()); assertEquals(ISOChronology.getInstance(LONDON), test.getChronology()); }
public void testConstructor_long_long3() throws Throwable { DateTime dt1 = new DateTime(2005, 7, 10, 1, 1, 1, 1); DateTime dt2 = new DateTime(2004, 6, 9, 0, 0, 0, 0); try { new Interval(dt1.getMillis(), dt2.getMillis()); fail(); } catch (IllegalArgumentException ex) { } }
public void testConstructor_Object_Chronology2() throws Throwable { DateTime dt1 = new DateTime(2004, 6, 9, 0, 0, 0, 0); DateTime dt2 = new DateTime(2005, 7, 10, 1, 1, 1, 1); Interval base = new Interval(dt1, dt2); Interval test = new Interval(base, null); assertEquals(dt1.getMillis(), test.getStartMillis()); assertEquals(dt2.getMillis(), test.getEndMillis()); assertEquals(ISOChronology.getInstance(), test.getChronology()); }
// ----------------------------------------------------------------------- public void testToDateTime_RI() { LocalTime base = new LocalTime(10, 20, 30, 40, COPTIC_PARIS); DateTime dt = new DateTime(0L); // LONDON zone assertEquals("1970-01-01T01:00:00.000+01:00", dt.toString()); DateTime test = base.toDateTime(dt); check(base, 10, 20, 30, 40); assertEquals("1970-01-01T01:00:00.000+01:00", dt.toString()); assertEquals("1970-01-01T10:20:30.040+01:00", test.toString()); }
public void testConstructor_long4_DateTimeZone() throws Throwable { DateTime dt = new DateTime(2006, 6, 9, 23, 59, 59, 999, PARIS); DateTime dtUTC = new DateTime(2006, 6, 9, 0, 0, 0, 0, DateTimeZone.UTC); LocalDate test = new LocalDate(dt.getMillis(), PARIS); assertEquals(ISO_UTC, test.getChronology()); assertEquals(2006, test.getYear()); assertEquals(6, test.getMonthOfYear()); assertEquals(9, test.getDayOfMonth()); assertEquals(dtUTC.getMillis(), test.getLocalMillis()); }
public void testConstructor_nullDateTimeZone() throws Throwable { DateTime dt = new DateTime(2005, 6, 8, 23, 59, 0, 0, LONDON); DateTimeUtils.setCurrentMillisFixed(dt.getMillis()); // 23:59 in London is 00:59 the following day in Paris LocalDate test = new LocalDate((DateTimeZone) null); assertEquals(ISO_UTC, test.getChronology()); assertEquals(2005, test.getYear()); assertEquals(6, test.getMonthOfYear()); assertEquals(8, test.getDayOfMonth()); }
public void testConstructor_RP_RI4() throws Throwable { DateTime dt = new DateTime(TEST_TIME_NOW); Period dur = new Period(1 * DateTimeConstants.MILLIS_PER_HOUR + 23L); long result = TEST_TIME_NOW; result = ISOChronology.getInstance().hours().add(result, -1); result = ISOChronology.getInstance().millis().add(result, -23); Interval test = new Interval(dur, dt); assertEquals(result, test.getStartMillis()); assertEquals(dt.getMillis(), test.getEndMillis()); }
// ----------------------------------------------------------------------- public void testConstructor_RP_RI1() throws Throwable { DateTime dt = new DateTime(TEST_TIME_NOW); Period dur = new Period(0, 6, 0, 0, 1, 0, 0, 0); long result = TEST_TIME_NOW; result = ISOChronology.getInstance().months().add(result, -6); result = ISOChronology.getInstance().hours().add(result, -1); Interval test = new Interval(dur, dt); assertEquals(result, test.getStartMillis()); assertEquals(dt.getMillis(), test.getEndMillis()); }
public Travel(int id, String title, String description, DateTime start, DateTime end) { this.id = id; this.start = start; this.end = end; this.title = title; this.description = description; days = new ArrayList<Integer>(); start.setBeginning(); end.setBeginning(); }
public static void duracion(Long id) { Competition competition = Competition.findById(id); DateTime startTime = new DateTime(competition.startTime); DateTime endTime = new DateTime(competition.endTime); DateTime duration = competition.duration; String inputDateTime = "HH:mm:ss"; String reprStartTime = startTime.toString(inputDateTime); renderText(reprStartTime); }
public void testConstructor_RP_RI3() throws Throwable { DateTime dt = new DateTime(TEST_TIME_NOW, CopticChronology.getInstanceUTC()); Period dur = new Period(0, 6, 0, 3, 1, 0, 0, 0, PeriodType.standard()); long result = TEST_TIME_NOW; result = CopticChronology.getInstanceUTC().months().add(result, -6); result = CopticChronology.getInstanceUTC().days().add(result, -3); result = CopticChronology.getInstanceUTC().hours().add(result, -1); Interval test = new Interval(dur, dt); assertEquals(result, test.getStartMillis()); assertEquals(dt.getMillis(), test.getEndMillis()); }
// ----------------------------------------------------------------------- public void testConstructor_RD_RI1() throws Throwable { long result = TEST_TIME_NOW; result = ISOChronology.getInstance().months().add(result, -6); result = ISOChronology.getInstance().hours().add(result, -1); DateTime dt = new DateTime(TEST_TIME_NOW); Duration dur = new Duration(TEST_TIME_NOW - result); Interval test = new Interval(dur, dt); assertEquals(result, test.getStartMillis()); assertEquals(dt.getMillis(), test.getEndMillis()); }
public String toString() { return "[Travel: id=" + id + " start=" + start.asStringDay() + " end=" + end.asStringDay() + " title=" + title + " desc=" + description + "]"; }
/** * Add a date to the list. The date will be updated to reflect the timezone of this list. * * @param date the date to add * @return true * @see List#add(java.lang.Object) */ public final boolean add(final Date date) { if (date instanceof DateTime) { if (isUtc()) { ((DateTime) date).setUtc(true); } else { ((DateTime) date).setTimeZone(getTimeZone()); } } else if (!Value.DATE.equals(getType())) { DateTime dateTime = new DateTime(date); dateTime.setTimeZone(getTimeZone()); return add((Object) dateTime); } return add((Object) date); }
/** * Sets the set of times of all the profiles. The set will contain one or more times as double * values, in order, from earliest to latest. * * @param times The times of all the profiles. * @param source * @throws VisADException if a VisAD failure occurs. * @throws RemoteException if a Java RMI failure occurs. */ public void setTimes(SampledSet times, SoundingDataNode source) throws VisADException, RemoteException { RealType timeType = (RealType) ((SetType) times.getType()).getDomain().getComponent(0); // use a LineDrawing because it's the simplest DisplayableData if (timesHolder == null) { timesHolder = new LineDrawing("times ref"); } /* * Add a data object to the display that has the right * time-centers. */ Field dummy = new FieldImpl(new FunctionType(timeType, AirTemperatureProfile.instance()), times); for (int i = 0, n = times.getLength(); i < n; i++) { dummy.setSample(i, AirTemperatureProfile.instance().missingData()); } timesHolder.setData(dummy); if (widget == null) { if (times.getLength() == 1) { DateTime time = new DateTime( new Real( timeType, times.indexToDouble(new int[] {0})[0][0], times.getSetUnits()[0])); widget = GuiUtils.wrap(new JLabel(time.toString())); dataNode.setTime(time); setSounding(0); } else { // // Set the animation. // Animation animation = getInternalAnimation(timeType); getSoundingView().setExternalAnimation(animation, getAnimationWidget()); aeroDisplay.addDisplayable(animation); aeroDisplay.addDisplayable(timesHolder); Container container = Box.createHorizontalBox(); // Wrap these components so they don't get stretched in the Y direction container.add(GuiUtils.wrap(getAnimationWidget().getContents(false))); // container.add(GuiUtils.wrap (animationWidget.getIndicatorComponent())); widget = container; } } }
private boolean compareTimeLists(List<DateTime> timesA, List<DateTime> timesB) { if (timesA.size() != timesB.size()) return false; Collections.sort(timesA); Collections.sort(timesB); for (int i = 0; i < timesA.size(); i++) { DateTime a = timesA.get(i); DateTime b = timesB.get(i); double test = Math.abs(a.getValue() - b.getValue()); if (test > 65.0) return false; // System.out.println("TTTTTTT = " + test ); } return true; }
protected boolean _setDevice(Device device, String ipAddress, int clientPort) { /* valid device? */ if (device == null) { return false; } /* validate ID address */ DataTransport dataXPort = device.getDataTransport(); if ((ipAddress != null) && !dataXPort.isValidIPAddress(ipAddress)) { Print.logError( "Invalid IPAddr: " + device.getAccountID() + "/" + device.getDeviceID() + " Found=" + ipAddress + " Expect=" + dataXPort.getIpAddressValid()); return false; } /* update device */ this.device = device; this.dataXPort = dataXPort; this.dataXPort.setIpAddressCurrent(ipAddress); // FLD_ipAddressCurrent this.dataXPort.setRemotePortCurrent(clientPort); // FLD_remotePortCurrent this.dataXPort.setDeviceCode(this.getDeviceCode()); // FLD_deviceCode this.device.setLastTotalConnectTime(DateTime.getCurrentTimeSec()); // FLD_lastTotalConnectTime /* ok */ return true; }
public DocumentReference copy() { DocumentReference dst = new DocumentReference(); dst.masterIdentifier = masterIdentifier == null ? null : masterIdentifier.copy(); dst.identifier = new ArrayList<Identifier>(); for (Identifier i : identifier) dst.identifier.add(i.copy()); dst.subject = subject == null ? null : subject.copy(); dst.type = type == null ? null : type.copy(); dst.subtype = subtype == null ? null : subtype.copy(); dst.author = new ArrayList<ResourceReference>(); for (ResourceReference i : author) dst.author.add(i.copy()); dst.custodian = custodian == null ? null : custodian.copy(); dst.authenticator = authenticator == null ? null : authenticator.copy(); dst.created = created == null ? null : created.copy(); dst.indexed = indexed == null ? null : indexed.copy(); dst.status = status == null ? null : status.copy(); dst.docStatus = docStatus == null ? null : docStatus.copy(); dst.supercedes = supercedes == null ? null : supercedes.copy(); dst.description = description == null ? null : description.copy(); dst.confidentiality = confidentiality == null ? null : confidentiality.copy(); dst.primaryLanguage = primaryLanguage == null ? null : primaryLanguage.copy(); dst.mimeType = mimeType == null ? null : mimeType.copy(); dst.format = format == null ? null : format.copy(); dst.size = size == null ? null : size.copy(); dst.hash = hash == null ? null : hash.copy(); dst.location = location == null ? null : location.copy(); dst.service = service == null ? null : service.copy(dst); dst.context = context == null ? null : context.copy(dst); return dst; }
public TravelDay getDate(DateTime date, DatabaseHelper db) { // return null if outside travel limits if (!date.dayBetween(start, end)) return null; // get matching day return db.findOrCreateTravelDay(this, date); }
public DiagnosticOrderEventComponent copy(DiagnosticOrder e) { DiagnosticOrderEventComponent dst = e.new DiagnosticOrderEventComponent(); dst.status = status == null ? null : status.copy(); dst.date = date == null ? null : date.copy(); dst.actor = actor == null ? null : actor.copy(); return dst; }