List of usage examples for org.joda.time DateTime getMinuteOfHour
public int getMinuteOfHour()
From source file:ch.emad.business.schuetu.zeit.Countdown.java
License:Apache License
public int getSecondsPlus2() { final DateTime t = this.ablauf.minus(this.letzte.getMillis()); final int minutes = t.getMinuteOfHour(); final int seconds = t.getSecondOfMinute(); return (minutes * 60 * 1000) + (seconds * 1000) + 2000; }
From source file:cherry.goods.util.JodaTimeUtil.java
License:Apache License
/** * @param dtm ???{@link DateTime}//from w ww.j av a 2 s. c o m * @return ?????{@link Calendar}(?{@link DateTime}??)???????????? */ public static Calendar getCalendar(DateTime dtm) { Calendar cal = Calendar.getInstance(dtm.getZone().toTimeZone()); cal.set(dtm.getYear(), dtm.getMonthOfYear() - 1, dtm.getDayOfMonth(), dtm.getHourOfDay(), dtm.getMinuteOfHour(), dtm.getSecondOfMinute()); cal.set(MILLISECOND, dtm.getMillisOfSecond()); return cal; }
From source file:com.alliander.osgp.adapter.protocol.oslp.elster.application.mapping.ConfigurationToOslpSetConfigurationRequestConverter.java
License:Open Source License
private String convertSummerTimeWinterTimeDetails(final DateTime dateTime) { LOGGER.info("dateTime: {}", dateTime); final StringBuilder timeDetails = new StringBuilder(); timeDetails.append(String.format("%02d", dateTime.getMonthOfYear())); timeDetails.append(dateTime.getDayOfWeek() - 1); timeDetails.append(String.format("%02d", dateTime.getHourOfDay())); timeDetails.append(String.format("%02d", dateTime.getMinuteOfHour())); final String formattedTimeDetails = timeDetails.toString(); LOGGER.info("formattedTimeDetails: {}", formattedTimeDetails); return formattedTimeDetails; }
From source file:com.almende.eve.agent.google.GoogleCalendarAgent.java
License:Apache License
/** * Quick create an event.//from ww w. j a v a2 s.c o m * * @param start * the start * @param end * the end * @param summary * the summary * @param location * the location * @param calendarId * the calendar id * @return the object node * @throws Exception * the exception */ public ObjectNode createEventQuick(@Optional @Name("start") String start, @Optional @Name("end") String end, @Optional @Name("summary") final String summary, @Optional @Name("location") final String location, @Optional @Name("calendarId") final String calendarId) throws Exception { final ObjectNode event = JOM.createObjectNode(); if (start == null) { // set start to current time, rounded to hours DateTime startDate = DateTime.now(); startDate = startDate.plusHours(1); startDate = startDate.minusMinutes(startDate.getMinuteOfHour()); startDate = startDate.minusSeconds(startDate.getSecondOfMinute()); startDate = startDate.minusMillis(startDate.getMillisOfSecond()); start = startDate.toString(); } final ObjectNode startObj = JOM.createObjectNode(); startObj.put("dateTime", start); event.put("start", startObj); if (end == null) { // set end to start +1 hour final DateTime startDate = new DateTime(start); final DateTime endDate = startDate.plusHours(1); end = endDate.toString(); } final ObjectNode endObj = JOM.createObjectNode(); endObj.put("dateTime", end); event.put("end", endObj); if (summary != null) { event.put("summary", summary); } if (location != null) { event.put("location", location); } return createEvent(event, calendarId); }
From source file:com.almende.eve.agent.MeetingAgent.java
License:Apache License
/** * Get the timestamp rounded to the next half hour * /*from w ww . j a va2 s . co m*/ * @return */ private DateTime getNextHalfHour() { DateTime next = DateTime.now(); next = next.minusMillis(next.getMillisOfSecond()); next = next.minusSeconds(next.getSecondOfMinute()); if (next.getMinuteOfHour() > 30) { next = next.minusMinutes(next.getMinuteOfHour()); next = next.plusMinutes(60); } else { next = next.minusMinutes(next.getMinuteOfHour()); next = next.plusMinutes(30); } return next; }
From source file:com.almende.pi5.common.agents.GraphAgent.java
License:Apache License
/** * Update time./*from w w w.j a va 2 s . com*/ */ @Access(AccessType.PUBLIC) public void updateTime() { DateTime now = DateTime.now(); now = now.plus((TIMESTEP - (now.getMinuteOfHour() % TIMESTEP)) * 60000 - (now.getSecondOfMinute() * 1000) - now.getMillisOfSecond()); if (!this.currentTimeslot.equals(now)) { this.currentTimeslot = now; LOG.fine(getId() + ": updateTime to: " + now); } }
From source file:com.barchart.feed.ddf.util.HelperDDF.java
License:BSD License
/** * from millisUTC into ddf "20100616124807". * //from w ww . j ava 2 s . c o m * @param millisUTC * the millis utc * @param zone * the zone * @return the long */ public static final long timeEncode(final long millisUTC, final DateTimeZone zone) { final DateTime dateTime = new DateTime(millisUTC, zone); long value = 0; final int year = dateTime.getYearOfEra(); value += year; value *= 100; final int month = dateTime.getMonthOfYear(); value += month; value *= 100; final int day = dateTime.getDayOfMonth(); value += day; value *= 100; final int hour = dateTime.getHourOfDay(); value += hour; value *= 100; final int minute = dateTime.getMinuteOfHour(); value += minute; value *= 100; final int second = dateTime.getSecondOfMinute(); value += second; return value; }
From source file:com.barchart.feed.test.replay.DDFLogDeframer.java
License:BSD License
static final void encodeTimeStamp(final String timestamp, final ByteBuffer buffer) { DateTime dateTime = timeParser.parseDateTime(timestamp); // base fields buffer.put(DDF_CENTURY); // century buffer.put(encodeTimeStampByte(dateTime.getYearOfCentury())); // year buffer.put(encodeTimeStampByte(dateTime.getMonthOfYear())); // month buffer.put(encodeTimeStampByte(dateTime.getDayOfMonth())); // day buffer.put(encodeTimeStampByte(dateTime.getHourOfDay())); // hours buffer.put(encodeTimeStampByte(dateTime.getMinuteOfHour())); // minutes buffer.put(encodeTimeStampByte(dateTime.getSecondOfMinute())); // seconds // milliseconds final int millisOfSecond = dateTime.getMillisOfSecond(); buffer.put((byte) (millisOfSecond & 0xFF)); // low byte buffer.put((byte) ((millisOfSecond >>> 8) & 0xFF)); // high byte }
From source file:com.cfelde.cron4joda.SchedulingPattern.java
License:Open Source License
/** * This methods returns true if the given timestamp (expressed as a UNIX-era * millis value) matches the pattern, according to the given time zone. * * @param timezone A time zone./*ww w . j ava2 s . com*/ * @param millis The timestamp, as a UNIX-era millis value. * @return true if the given timestamp matches the pattern. */ public boolean match(DateTime dt) { int minute = dt.getMinuteOfHour(); int hour = dt.getHourOfDay(); int dayOfMonth = dt.getDayOfMonth(); int month = dt.getMonthOfYear(); //gc.get(Calendar.MONTH) + 1; int dayOfWeek = dt.getDayOfWeek(); //gc.get(Calendar.DAY_OF_WEEK) - 1; for (int i = 0; i < matcherSize; i++) { ValueMatcher minuteMatcher = (ValueMatcher) minuteMatchers.get(i); ValueMatcher hourMatcher = (ValueMatcher) hourMatchers.get(i); ValueMatcher dayOfMonthMatcher = (ValueMatcher) dayOfMonthMatchers.get(i); ValueMatcher monthMatcher = (ValueMatcher) monthMatchers.get(i); ValueMatcher dayOfWeekMatcher = (ValueMatcher) dayOfWeekMatchers.get(i); boolean eval = minuteMatcher.match(minute) && hourMatcher.match(hour) && ((dayOfMonthMatcher instanceof DayOfMonthValueMatcher) ? ((DayOfMonthValueMatcher) dayOfMonthMatcher).match(dayOfMonth, month, dt.year().getField().isLeap(dt.getMillis())) /*gc.isLeapYear(year))*/ : dayOfMonthMatcher.match(dayOfMonth)) && monthMatcher.match(month) && dayOfWeekMatcher.match(dayOfWeek); if (eval) { return true; } } return false; }
From source file:com.citrix.g2w.webdriver.pages.BasePage.java
License:Open Source License
/** * Method to create date and time object based on input. By default 1 hour * will be added if hrs parameter is 0.//from ww w .j a v a2s . c o m * * @param days * (create date and time object based on number of days) * @param hrs * (create date and time object based on number of hours) * @param mins * (create date and time object based on number of minutes) * @return startDate (return date and time object based on the parameters) */ public DateTime getDateTime(final int days, final int hrs, final int mins) { DateTime startDate = this.getDateTime(); if (startDate.getMinuteOfHour() < 60) { startDate = this.getAgedDateTime(startDate.plusDays(days)).plusHours(hrs + 1).withMinuteOfHour(mins) .withSecondOfMinute(0).withMillisOfSecond(0); } return startDate; }