List of usage examples for org.joda.time MutableDateTime setHourOfDay
public void setHourOfDay(final int hourOfDay)
From source file:ch.windmobile.server.mongo.MongoDataSource.java
License:Open Source License
static protected DateTime getExpirationDate(DateTime now, DateTime lastUpdate) { MutableDateTime expirationDate = new MutableDateTime(lastUpdate.getZone()); if (isSummerFrequency(now)) { expirationDate.setMillis(lastUpdate.getMillis() + 20 * 60 * 1000); if (expirationDate.getHourOfDay() >= 20) { expirationDate.addDays(1);/*from w w w . java 2 s. c om*/ expirationDate.setHourOfDay(8); expirationDate.setMinuteOfHour(0); expirationDate.setSecondOfMinute(0); } } else { expirationDate.setMillis(lastUpdate.getMillis() + 60 * 60 * 1000); if (expirationDate.getHourOfDay() >= 17) { expirationDate.addDays(1); expirationDate.setHourOfDay(9); expirationDate.setMinuteOfHour(0); expirationDate.setSecondOfMinute(0); } } return expirationDate.toDateTime(); }
From source file:com.carmatech.cassandra.ShardingFrequency.java
License:Apache License
public static long calculateBucket(final long timestamp, final ShardingFrequency frequency) { final MutableDateTime dateTime = new MutableDateTime(timestamp); if (frequency.compareTo(SECONDLY) >= 0) dateTime.setMillisOfSecond(0);/*ww w . j a va2 s . c o m*/ if (frequency.compareTo(MINUTELY) >= 0) dateTime.setSecondOfMinute(0); if (frequency.compareTo(HOURLY) >= 0) dateTime.setMinuteOfHour(0); if (frequency.compareTo(DAILY) >= 0) dateTime.setHourOfDay(0); if (frequency.compareTo(WEEKLY) >= 0) dateTime.setDayOfWeek(1); if (frequency.compareTo(MONTHLY) >= 0) dateTime.setDayOfMonth(1); return dateTime.getMillis(); }
From source file:com.ning.metrics.serialization.util.DateTimeUtil.java
License:Apache License
public DateTime truncateToDay(ReadableDateTime time) { MutableDateTime result = new MutableDateTime(time); result.setMillisOfSecond(0);//from ww w. j a v a2 s . c o m result.setSecondOfMinute(0); result.setMinuteOfHour(0); result.setHourOfDay(0); return new DateTime(result); }
From source file:com.ning.metrics.serialization.util.DateTimeUtil.java
License:Apache License
public DateTime truncateToMonth(ReadableDateTime time) { MutableDateTime result = new MutableDateTime(time); result.setMillisOfSecond(0);/*from w w w .j av a 2 s .c o m*/ result.setSecondOfMinute(0); result.setMinuteOfHour(0); result.setHourOfDay(0); result.setDayOfMonth(1); return new DateTime(result); }
From source file:com.ning.metrics.serialization.util.DateTimeUtil.java
License:Apache License
public DateTime truncateToWeek(ReadableDateTime time) { MutableDateTime result = new MutableDateTime(time); result.setMillisOfSecond(0);// ww w .j av a2 s. c o m result.setSecondOfMinute(0); result.setMinuteOfHour(0); result.setHourOfDay(0); result.setHourOfDay(0); if (time.getDayOfWeek() != 7) { result.setDayOfWeek(1); result.add(Days.ONE.multipliedBy(-1)); } return new DateTime(result); }
From source file:com.ning.metrics.serialization.util.DateTimeUtil.java
License:Apache License
public DateTime truncateToYear(ReadableDateTime time) { MutableDateTime result = new MutableDateTime(time); result.setMillisOfSecond(0);// ww w . java 2 s . co m result.setSecondOfMinute(0); result.setMinuteOfHour(0); result.setHourOfDay(0); result.setDayOfMonth(1); result.setMonthOfYear(1); return new DateTime(result); }
From source file:com.soen.hasslefree.beans.PhysicianAvailabilityBean.java
public String addAvailability() { String[] startSplit = startTimeHolder.split(":"); String[] endSplit = endTimeHolder.split(":"); MutableDateTime startDateTime = new MutableDateTime(dateHolder); MutableDateTime endDateTime = new MutableDateTime(dateHolder); String patientEmail = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap() .get("patientEmail"); // Setting start time value from string input startDateTime.setHourOfDay(Integer.parseInt(startSplit[0])); startDateTime.setMinuteOfHour(Integer.parseInt(startSplit[1])); // Setting end time value from string input endDateTime.setHourOfDay(Integer.parseInt(endSplit[0])); endDateTime.setMinuteOfHour(Integer.parseInt(endSplit[1])); PhysicianAvailability pa = new PhysicianAvailability(); pa.setStartTime(startDateTime.toDateTime()); pa.setEndTime(endDateTime.toDateTime()); pa.setRelatedPhysician(Physician.getPhysicianByEmail(patientEmail)); pa.savePhysicianAvailability();/* w ww . j a v a 2s .co m*/ return "myAvailabilities"; }
From source file:com.tmathmeyer.sentinel.ui.views.day.collisiondetection.DayPanel.java
License:Open Source License
private DateTime getTimeAtCursor() { Point m = MouseInfo.getPointerInfo().getLocation(); Point p = getLocationOnScreen(); MutableDateTime d = date.toMutableDateTime(); m.y -= offset;/*from w w w.j ava 2s . c om*/ if (m.y < p.y) m.y = p.y; if (m.y > 1440) m.y = 1440; d.setHourOfDay((m.y - p.y) / 60); int min = (m.y - p.y) % 60; if (min >= 7 && min < 23) min = 15; if (min < 7) min = 0; if (min >= 23 && min < 38) min = 30; if (min >= 38 && min < 55) min = 45; if (min >= 55) { min = 0; d.addHours(1); } d.setMinuteOfHour(min); return d.toDateTime(); }
From source file:com.yahoo.bard.webservice.sql.helper.SqlTimeConverter.java
License:Apache License
/** * Sets the correct part of a {@link DateTime} corresponding to a * {@link SqlDatePartFunction}./* ww w. j av a 2 s . c o m*/ * * @param value The value to be set for the dateTime with the sqlDatePartFn * @param sqlDatePartFn The function used to extract part of a date with sql. * @param dateTime The original dateTime to create a copy of. */ protected void setDateTime(int value, SqlDatePartFunction sqlDatePartFn, MutableDateTime dateTime) { if (YEAR.equals(sqlDatePartFn)) { dateTime.setYear(value); } else if (MONTH.equals(sqlDatePartFn)) { dateTime.setMonthOfYear(value); } else if (WEEK.equals(sqlDatePartFn)) { dateTime.setWeekOfWeekyear(value); dateTime.setDayOfWeek(1); } else if (DAYOFYEAR.equals(sqlDatePartFn)) { dateTime.setDayOfYear(value); } else if (HOUR.equals(sqlDatePartFn)) { dateTime.setHourOfDay(value); } else if (MINUTE.equals(sqlDatePartFn)) { dateTime.setMinuteOfHour(value); } else if (SECOND.equals(sqlDatePartFn)) { dateTime.setSecondOfMinute(value); } else { throw new IllegalArgumentException("Can't set value " + value + " for " + sqlDatePartFn); } }
From source file:net.naonedbus.rest.controller.impl.HoraireController.java
License:Open Source License
/** * Rcuprer les horaires depuis le WebService. * /*from w w w.j a va2 s . co m*/ * @throws IOException * @throws MalformedURLException */ public synchronized List<Horaire> getAllFromWeb(final Arret arret, final DateMidnight date) throws IOException { final UrlBuilder url = new UrlBuilder(PATH); final List<HoraireNode> horaires; List<Horaire> result = null; url.addSegment(arret.getCodeArret()); url.addSegment(arret.getCodeLigne()); url.addSegment(arret.getCodeSens()); url.addSegment(mDateFormat.format(date.toDate())); final HoraireContainer content = parseJsonObject(url.getUrl()); MutableDateTime mutableDateTime = new MutableDateTime(date); if (content != null) { horaires = content.horaires; result = new ArrayList<Horaire>(); int lastHour = Integer.MIN_VALUE; // Transformation des horaires TAN en horaire naonedbus. for (final HoraireNode horaireTan : horaires) { final int hour = Integer.parseInt(horaireTan.heure.replaceAll("[^\\d.]", "")); mutableDateTime.setHourOfDay(hour); // Changement de jour if (hour < lastHour) { mutableDateTime.addDays(1); } lastHour = hour; for (final String passage : horaireTan.passages) { int minute = Integer.parseInt(passage.replaceAll("[^\\d.]", "")); mutableDateTime.setMinuteOfHour(minute); final Horaire horaire = new Horaire(); horaire.setJour(date); horaire.setHoraire(mutableDateTime.toDateTime()); horaire.setTerminus(parseTerminus(passage, content.notes)); horaire.setSection(new DateMidnight(horaire.getHoraire())); result.add(horaire); } } } return result; }