List of usage examples for org.joda.time LocalTime toDateTimeToday
public DateTime toDateTimeToday(DateTimeZone zone)
From source file:org.fixb.quickfix.QuickFixFieldMapBuilder.java
License:Apache License
protected FixMessageBuilder<M> setField(final FieldMap message, final int tag, final LocalTime value) { message.setUtcTimeOnly(tag, value.toDateTimeToday(DateTimeZone.UTC).toDate()); return this; }
From source file:org.jasig.portlet.jaxb.util.JodaTypeConverter.java
License:Apache License
public static String printTime(LocalTime localTime) { final DateTime dateTime = localTime.toDateTimeToday(DateTimeZone.UTC); final GregorianCalendar cal = dateTime.toGregorianCalendar(); return DatatypeConverter.printTime(cal); }
From source file:org.kalypso.model.hydrology.internal.binding.cm.LinearSumGenerator.java
License:Open Source License
@Override public void adjustValidities() { /* Get the valid from date and the valid to date. */ final Date validFrom = getValidFrom(); final Date validTo = getValidTo(); if (validFrom == null || validTo == null) return;/*from ww w . ja v a2 s . c om*/ /* Get the valid from date. */ final Calendar validFromCalendar = Calendar.getInstance(KalypsoCorePlugin.getDefault().getTimeZone()); validFromCalendar.setTime(validFrom); /* Get the valid to date. */ final Calendar validToCalendar = Calendar.getInstance(KalypsoCorePlugin.getDefault().getTimeZone()); validToCalendar.setTime(validTo); /* Get the timestamp. */ final LocalTime timestamp = getTimestamp(); if (timestamp != null) { /* Convert to a date with the kalypso timezone. */ /* The date fields are ignored. */ final DateTime timestampUTC = timestamp .toDateTimeToday(DateTimeZone.forTimeZone(TimeZone.getTimeZone("UTC"))); //$NON-NLS-1$ final DateTime timestampDate = new DateTime(timestampUTC.toDate(), DateTimeZone.forTimeZone(KalypsoCorePlugin.getDefault().getTimeZone())); /* With a timestamp adjust the hours and the minutes accordingly. */ validFromCalendar.set(Calendar.HOUR_OF_DAY, timestampDate.getHourOfDay()); validFromCalendar.set(Calendar.MINUTE, timestampDate.getMinuteOfHour()); validToCalendar.set(Calendar.HOUR_OF_DAY, timestampDate.getHourOfDay()); validToCalendar.set(Calendar.MINUTE, timestampDate.getMinuteOfHour()); } else { /* Without a timestemp set the hours and the minutes to zero. */ validFromCalendar.set(Calendar.HOUR_OF_DAY, 0); validFromCalendar.set(Calendar.MINUTE, 0); validToCalendar.set(Calendar.HOUR_OF_DAY, 0); validToCalendar.set(Calendar.MINUTE, 0); } /* Always set the seconds and milliseconds to zero. */ validFromCalendar.set(Calendar.SECOND, 0); validFromCalendar.set(Calendar.MILLISECOND, 0); validToCalendar.set(Calendar.SECOND, 0); validToCalendar.set(Calendar.MILLISECOND, 0); /* Set the properties. */ setProperty(PROPERTY_VALID_FROM, DateUtilities.toXMLGregorianCalendar(validFromCalendar.getTime())); setProperty(PROPERTY_VALID_TO, DateUtilities.toXMLGregorianCalendar(validToCalendar.getTime())); }
From source file:org.kalypso.ogc.sensor.util.TimestampHelper.java
License:Open Source License
/** * This function converts the timestamp text (e.g. 11:00) into the kalypso timezone. * //from w ww . j ava 2s .c om * @param timestampText * The timestamp text in UTC. * @return The timestamp text in the kalypso timezone. */ public static String convertToKalypsoTimezone(final String timestampText) { /* Nothing to do. */ if (timestampText == null || timestampText.length() == 0) return ""; //$NON-NLS-1$ /* Get the timestamp in UTC. */ final LocalTime timestamp = TimestampHelper.parseTimestamp(timestampText); /* Convert to a date with the kalypso timezone. */ /* The date fields are ignored. */ final DateTime timestampUTC = timestamp .toDateTimeToday(DateTimeZone.forTimeZone(TimeZone.getTimeZone("UTC"))); //$NON-NLS-1$ final DateTime timestampZone = new DateTime(timestampUTC.toDate(), DateTimeZone.forTimeZone(KalypsoCorePlugin.getDefault().getTimeZone())); return timestampZone.toString("HH:mm"); //$NON-NLS-1$ }
From source file:org.kalypso.ui.rrm.internal.calccase.CatchmentModelHelper.java
License:Open Source License
private static DateRange modifyWithTimestamp(final LocalTime timestamp, final DateTime simulationStart, final DateTime simulationEnd) { /* Nothing to do. */ if (timestamp == null) return new DateRange(simulationStart.toDate(), simulationEnd.toDate()); /* Convert to a date with the kalypso timezone. */ /* The date fields are ignored. */ final DateTime timestampUTC = timestamp .toDateTimeToday(DateTimeZone.forTimeZone(TimeZone.getTimeZone("UTC"))); //$NON-NLS-1$ final DateTime timestampDate = new DateTime(timestampUTC.toDate(), DateTimeZone.forTimeZone(KalypsoCorePlugin.getDefault().getTimeZone())); /* Further adjust range by predefined time. */ final DateTime startWithTime = simulationStart.withTime(timestampDate.getHourOfDay(), timestampDate.getMinuteOfHour(), timestampDate.getSecondOfMinute(), timestampDate.getMillisOfSecond()); final DateTime endWithTime = simulationEnd.withTime(timestampDate.getHourOfDay(), timestampDate.getMinuteOfHour(), timestampDate.getSecondOfMinute(), timestampDate.getMillisOfSecond()); return new DateRange(startWithTime.toDate(), endWithTime.toDate()); }
From source file:org.kalypso.ui.rrm.internal.calccase.CatchmentModelHelper.java
License:Open Source License
/** * This function calculates the range for the timeseries to be generated. The range equals the range defined in the * simulation adjusted as follows://from w w w . j a v a 2s. com * <ul> * <li>1 timestep earlier</li> * <li>3 timesteps later</li> * </ul> * * @param control * The na control. * @param timestep * The timestep. * @param timestamp * The timestamp in UTC. * @return The date range. */ public static DateRange getRange(final NAControl control, final Period timestep, final LocalTime timestamp) { final Date simulationStart = control.getSimulationStart(); final Date simulationEnd = control.getSimulationEnd(); final DateTime start = new DateTime(simulationStart); final DateTime end = new DateTime(simulationEnd); final DateTime adjustedStart = start.minus(timestep); final DateTime adjustedEnd = end.plus(timestep).plus(timestep).plus(timestep); if (timestep.getDays() == 0 || timestamp == null) return new DateRange(adjustedStart.toDate(), adjustedEnd.toDate()); /* Convert to a date with the kalypso timezone. */ /* The date fields are ignored. */ final DateTime timestampUTC = timestamp .toDateTimeToday(DateTimeZone.forTimeZone(TimeZone.getTimeZone("UTC"))); //$NON-NLS-1$ final DateTime timestampDate = new DateTime(timestampUTC.toDate(), DateTimeZone.forTimeZone(KalypsoCorePlugin.getDefault().getTimeZone())); /* Further adjust range by predefined time. */ final DateTime startWithTime = adjustedStart.withTime(timestampDate.getHourOfDay(), timestampDate.getMinuteOfHour(), timestampDate.getSecondOfMinute(), timestampDate.getMillisOfSecond()); final DateTime endWithTime = adjustedEnd.withTime(timestampDate.getHourOfDay(), timestampDate.getMinuteOfHour(), timestampDate.getSecondOfMinute(), timestampDate.getMillisOfSecond()); /* New start must always be before unadjusted start, fix, if this is not the case. */ DateTime startWithTimeFixed; if (startWithTime.isAfter(adjustedStart)) startWithTimeFixed = startWithTime.minus(timestep); else startWithTimeFixed = startWithTime; /* New end must always be after unadjusted end, fix, if this is not the case. */ DateTime endWithTimeFixed; if (endWithTime.isBefore(adjustedEnd)) endWithTimeFixed = endWithTime.plus(timestep); else endWithTimeFixed = endWithTime; return new DateRange(startWithTimeFixed.toDate(), endWithTimeFixed.toDate()); }