List of usage examples for org.joda.time DateTime getMinuteOfHour
public int getMinuteOfHour()
From source file:org.egov.eventnotification.service.ScheduleService.java
License:Open Source License
public List<Schedule> getAllSchedule() { List<Schedule> notificationScheduleList = null; notificationScheduleList = scheduleRepository.findByOrderByIdDesc(); if (!notificationScheduleList.isEmpty()) for (Schedule notificationSchedule : notificationScheduleList) { EventDetails details = new EventDetails(); DateTime sd = new DateTime(notificationSchedule.getStartDate()); details.setStartDt(getDate(getDefaultFormattedDate(notificationSchedule.getStartDate()), DDMMYYYY)); if (sd.getHourOfDay() < MAX_TEN) details.setStartHH(ZERO + String.valueOf(sd.getHourOfDay())); else//from www. j a va2s .c o m details.setStartHH(String.valueOf(sd.getHourOfDay())); if (sd.getMinuteOfHour() < MAX_TEN) details.setStartMM(ZERO + String.valueOf(sd.getMinuteOfHour())); else details.setStartMM(String.valueOf(sd.getMinuteOfHour())); notificationSchedule.setDetails(details); } return notificationScheduleList; }
From source file:org.egov.eventnotification.service.ScheduleService.java
License:Open Source License
public Schedule getScheduleById(Long id) { Schedule schedule = scheduleRepository.findOne(id); EventDetails details = new EventDetails(); DateTime sd = new DateTime(schedule.getStartDate()); details.setStartDt(getDate(getDefaultFormattedDate(schedule.getStartDate()), DDMMYYYY)); if (sd.getHourOfDay() < MAX_TEN) details.setStartHH(ZERO + String.valueOf(sd.getHourOfDay())); else// w w w. j a v a 2s . com details.setStartHH(String.valueOf(sd.getHourOfDay())); if (sd.getMinuteOfHour() < MAX_TEN) details.setStartMM(ZERO + String.valueOf(sd.getMinuteOfHour())); else details.setStartMM(String.valueOf(sd.getMinuteOfHour())); schedule.setDetails(details); return schedule; }
From source file:org.epics.archiverappliance.common.TimeUtils.java
/** * Returns a partition name for the given epoch second based on the partition granularity. * /*from ww w. ja v a 2s. c o m*/ * @param epochseconds * @return */ public static String getPartitionName(long epochSeconds, PartitionGranularity granularity) { DateTime dateTime = new DateTime(epochSeconds * 1000, DateTimeZone.UTC); switch (granularity) { case PARTITION_YEAR: return "" + dateTime.getYear(); case PARTITION_MONTH: return "" + dateTime.getYear() + "_" + (dateTime.getMonthOfYear() < 10 ? TWO_DIGIT_EXPANSIONS[dateTime.getMonthOfYear()] : dateTime.getMonthOfYear()); case PARTITION_DAY: return "" + dateTime.getYear() + "_" + (dateTime.getMonthOfYear() < 10 ? TWO_DIGIT_EXPANSIONS[dateTime.getMonthOfYear()] : dateTime.getMonthOfYear()) + "_" + (dateTime.getDayOfMonth() < 10 ? TWO_DIGIT_EXPANSIONS[dateTime.getDayOfMonth()] : dateTime.getDayOfMonth()); case PARTITION_HOUR: return "" + dateTime.getYear() + "_" + (dateTime.getMonthOfYear() < 10 ? TWO_DIGIT_EXPANSIONS[dateTime.getMonthOfYear()] : dateTime.getMonthOfYear()) + "_" + (dateTime.getDayOfMonth() < 10 ? TWO_DIGIT_EXPANSIONS[dateTime.getDayOfMonth()] : dateTime.getDayOfMonth()) + "_" + (dateTime.getHourOfDay() < 10 ? TWO_DIGIT_EXPANSIONS[dateTime.getHourOfDay()] : dateTime.getHourOfDay()); case PARTITION_5MIN: case PARTITION_15MIN: case PARTITION_30MIN: int approxMinutesPerChunk = granularity.getApproxMinutesPerChunk(); int startOfPartition_Min = (dateTime.getMinuteOfHour() / approxMinutesPerChunk) * approxMinutesPerChunk; return "" + dateTime.getYear() + "_" + (dateTime.getMonthOfYear() < 10 ? TWO_DIGIT_EXPANSIONS[dateTime.getMonthOfYear()] : dateTime.getMonthOfYear()) + "_" + (dateTime.getDayOfMonth() < 10 ? TWO_DIGIT_EXPANSIONS[dateTime.getDayOfMonth()] : dateTime.getDayOfMonth()) + "_" + (dateTime.getHourOfDay() < 10 ? TWO_DIGIT_EXPANSIONS[dateTime.getHourOfDay()] : dateTime.getHourOfDay()) + "_" + (startOfPartition_Min < 10 ? TWO_DIGIT_EXPANSIONS[startOfPartition_Min] : startOfPartition_Min); default: throw new UnsupportedOperationException("Invalid Partition type " + granularity); } }
From source file:org.epics.archiverappliance.common.TimeUtils.java
/** * Given an epoch seconds and a granularity, this method gives you the first second in the next partition as epoch seconds. * @param epochSeconds//from w w w . j a v a 2 s . c o m * @param granularity * @return */ public static long getNextPartitionFirstSecond(long epochSeconds, PartitionGranularity granularity) { DateTime dateTime = new DateTime(epochSeconds * 1000, DateTimeZone.UTC); DateTime nextPartitionFirstSecond = null; switch (granularity) { case PARTITION_YEAR: nextPartitionFirstSecond = dateTime.plusYears(1).withMonthOfYear(1).withDayOfMonth(1).withHourOfDay(0) .withMinuteOfHour(0).withSecondOfMinute(0); return nextPartitionFirstSecond.getMillis() / 1000; case PARTITION_MONTH: nextPartitionFirstSecond = dateTime.plusMonths(1).withDayOfMonth(1).withHourOfDay(0).withMinuteOfHour(0) .withSecondOfMinute(0); return nextPartitionFirstSecond.getMillis() / 1000; case PARTITION_DAY: nextPartitionFirstSecond = dateTime.plusDays(1).withHourOfDay(0).withMinuteOfHour(0) .withSecondOfMinute(0); return nextPartitionFirstSecond.getMillis() / 1000; case PARTITION_HOUR: nextPartitionFirstSecond = dateTime.plusHours(1).withMinuteOfHour(0).withSecondOfMinute(0); return nextPartitionFirstSecond.getMillis() / 1000; case PARTITION_5MIN: case PARTITION_15MIN: case PARTITION_30MIN: int approxMinutesPerChunk = granularity.getApproxMinutesPerChunk(); DateTime nextPartForMin = dateTime.plusMinutes(approxMinutesPerChunk); int startOfPartitionForMin = (nextPartForMin.getMinuteOfHour() / approxMinutesPerChunk) * approxMinutesPerChunk; nextPartitionFirstSecond = nextPartForMin.withMinuteOfHour(startOfPartitionForMin) .withSecondOfMinute(0); return nextPartitionFirstSecond.getMillis() / 1000; default: throw new UnsupportedOperationException("Invalid Partition type " + granularity); } }
From source file:org.epics.archiverappliance.common.TimeUtils.java
/** * Given an epoch seconds and a granularity, this method gives you the last second in the previous partition as epoch seconds. * @param epochSeconds/*from w ww . ja v a2s .c o m*/ * @param granularity * @return */ public static long getPreviousPartitionLastSecond(long epochSeconds, PartitionGranularity granularity) { DateTime dateTime = new DateTime(epochSeconds * 1000, DateTimeZone.UTC); DateTime previousPartitionLastSecond = null; switch (granularity) { case PARTITION_YEAR: previousPartitionLastSecond = dateTime.minusYears(1).withMonthOfYear(12).withDayOfMonth(31) .withHourOfDay(23).withMinuteOfHour(59).withSecondOfMinute(59); return previousPartitionLastSecond.getMillis() / 1000; case PARTITION_MONTH: previousPartitionLastSecond = dateTime.withDayOfMonth(1).minusDays(1).withHourOfDay(23) .withMinuteOfHour(59).withSecondOfMinute(59); return previousPartitionLastSecond.getMillis() / 1000; case PARTITION_DAY: previousPartitionLastSecond = dateTime.minusDays(1).withHourOfDay(23).withMinuteOfHour(59) .withSecondOfMinute(59); return previousPartitionLastSecond.getMillis() / 1000; case PARTITION_HOUR: previousPartitionLastSecond = dateTime.minusHours(1).withMinuteOfHour(59).withSecondOfMinute(59); return previousPartitionLastSecond.getMillis() / 1000; case PARTITION_5MIN: case PARTITION_15MIN: case PARTITION_30MIN: int approxMinutesPerChunk = granularity.getApproxMinutesPerChunk(); int startOfPartition_Min = (dateTime.getMinuteOfHour() / approxMinutesPerChunk) * approxMinutesPerChunk; previousPartitionLastSecond = dateTime.withMinuteOfHour(startOfPartition_Min).withSecondOfMinute(0) .minusSeconds(1); return previousPartitionLastSecond.getMillis() / 1000; default: throw new UnsupportedOperationException("Invalid Partition type " + granularity); } }
From source file:org.everit.jira.timetracker.plugin.util.DateTimeConverterUtil.java
License:Apache License
/** * Convert joda DateTime to java Date. Convert the date and time without Time Zone correction. * (the joda DateTime toDate metod add the time zone). * * @param dateTime/*from w ww .j a v a 2s . co m*/ * The dateTime. * @return The new date. */ @SuppressWarnings("deprecation") public static Date convertDateTimeToDate(final DateTime dateTime) { return new Date(dateTime.getYear() - YEAR_1900, dateTime.getMonthOfYear() - 1, dateTime.getDayOfMonth(), dateTime.getHourOfDay(), dateTime.getMinuteOfHour(), dateTime.getSecondOfMinute()); }
From source file:org.fenixedu.academic.service.CreateUnavailablePeriod.java
License:Open Source License
private static void sendEmail(Person person, DateTime begin, DateTime end, String justification, List<VigilantGroup> groups) { for (VigilantGroup group : groups) { String bccs = group.getContactEmail(); String beginDate = begin.getDayOfMonth() + "/" + begin.getMonthOfYear() + "/" + begin.getYear() + " - " + String.format("%02d", begin.getHourOfDay()) + ":" + String.format("%02d", begin.getMinuteOfHour()) + "h"; String endDate = end.getDayOfMonth() + "/" + end.getMonthOfYear() + "/" + end.getYear() + " - " + String.format("%02d", end.getHourOfDay()) + ":" + String.format("%02d", end.getMinuteOfHour()) + "h"; ;//www .j ava 2 s . co m String message = BundleUtil.getString("resources.VigilancyResources", "email.convoke.unavailablePeriod", new String[] { person.getName(), beginDate, endDate, justification }); String subject = BundleUtil.getString("resources.VigilancyResources", "email.convoke.unavailablePeriod.subject", new String[] { group.getName() }); Sender sender = Bennu.getInstance().getSystemSender(); new Message(sender, new ConcreteReplyTo(group.getContactEmail()).asCollection(), Collections.EMPTY_LIST, subject, message, bccs); } }
From source file:org.fenixedu.learning.servlets.FenixEduLearningContextListener.java
License:Open Source License
private static int hasTime(DateTime proposedDiscussed) { if (proposedDiscussed.getHourOfDay() == 0 && proposedDiscussed.getMinuteOfHour() == 0) { return 0; } else {/* ww w . ja v a2 s. c om*/ return 1; } }
From source file:org.fenixedu.treasury.services.integration.erp.ERPExporter.java
License:Open Source License
private XMLGregorianCalendar convertToXMLDateTime(DatatypeFactory dataTypeFactory, DateTime documentDate) { return dataTypeFactory.newXMLGregorianCalendar(documentDate.getYear(), documentDate.getMonthOfYear(), documentDate.getDayOfMonth(), documentDate.getHourOfDay(), documentDate.getMinuteOfHour(), documentDate.getSecondOfMinute(), 0, DatatypeConstants.FIELD_UNDEFINED); }
From source file:org.forgerock.openidm.util.DateUtil.java
License:CDDL license
/** * Returns a {@link String} representing a scheduler expression of the supplied date. The scheduler expression is of * the form: "{second} {minute} {hour} {day} {month} ? {year}". * * For example, a scheduler expression for January 3, 2016 at 04:56 AM would be: "0 56 4 3 1 ? 2016". * /*from w w w . j av a 2 s. c o m*/ * @param intervalString a {@link String} object representing an ISO 8601 time interval. * @return a {@link String} representing a scheduler expression of the supplied date. * @throws IllegalArgumentException if an error occurs while parsing the intervalString. */ public String getSchedulerExpression(DateTime date) throws IllegalArgumentException { StringBuilder sb = new StringBuilder().append(date.getSecondOfMinute()).append(" ") .append(date.getMinuteOfHour()).append(" ").append(date.getHourOfDay()).append(" ") .append(date.getDayOfMonth()).append(" ").append(date.getMonthOfYear()).append(" ").append("? ") .append(date.getYear()); return sb.toString(); }