DateTimeZone timeZone = DateTimeZone.forID( "America/Montreal" ); DateTime now = DateTime.now( timeZone ); int minuteOfDayNow = now.getMinuteOfDay();
/** * @return minutes since midnight today! */ private long generateEpochValue() { return new DateTime().getMinuteOfDay(); }
@Test public void learnHowManyMinutesPassedToday() { DateTime time = DateTimeFormat.forPattern("HH:mm").parseDateTime("11:34"); System.out.println(time.getMinuteOfDay()); System.out.println(DateTime.now().getMinuteOfDay()); }
/** * @return The path of a minute file. This file is the smallest chunk of data. */ public Path getMinuteFilePath() { return getDayDirectoryPath().resolve(Integer.toString(timestamp.getMinuteOfDay())); }
@SuppressWarnings("deprecation") public static Date parseJodaDate(DateTime jodaDate) { int year = jodaDate.getYear(); int month = jodaDate.getMonthOfYear(); int day = jodaDate.getDayOfMonth(); int hour = jodaDate.getHourOfDay(); int min = jodaDate.getMinuteOfDay(); int sec = jodaDate.getSecondOfMinute(); // arghh Date date = new Date(year-1900, month, day, hour, min, sec); return date; }
private String getDayNumberString(int dayDelta) { StringBuilder b = new StringBuilder(); if (getBeginDateTime().getMinuteOfDay() == 0) { DateTime currStart = getBeginDateTime().plusDays(dayDelta); b.append(currStart.toString("d")); } else { DateTime currStart = getBeginDateTime().plusDays(dayDelta); DateTime currEnd = getBeginDateTime().plusDays(dayDelta); b.append(currStart.toString("d HH:mm")); b.append(" - "); //TODO: should this be currEnd??? b.append(currStart.toString("d HH:mm")); } return b.toString(); }
minutesDiff = dt1.getMinuteOfDay() - dt2.getMinuteOfDay(); } else { minutesDiff = 0;
int day = dateTime.getDayOfYear(); int hour = dateTime.getHourOfDay(); int minute = dateTime.getMinuteOfDay();
int day = dateTime.getDayOfYear(); int hour = dateTime.getHourOfDay(); int minute = dateTime.getMinuteOfDay();
/** * Assumption of 7 "days" per week, or 7 "blocks" per row. * * @return A list of string titles for each row block (day) */ public List<String> getCalendarDayHeadings() { List<String> dayStrings = new ArrayList<String>(7); // always render from Sunday int firstDay = 0 - getBeginDateTime().getDayOfWeek(); int lastDay = firstDay + 7; if (getBeginDateTime().getMinuteOfDay() == 0) { // "Standard" days. for (int i = firstDay; i < lastDay; i++) { DateTime currDay = getBeginDateTime().plusDays(i); dayStrings.add(currDay.toString("E")); } } else { // Day Split Strings for (int i = firstDay; i < lastDay; i++) { StringBuilder builder = new StringBuilder(""); DateTime currStart = getBeginDateTime().plusDays(i); DateTime currEnd = getBeginDateTime().plusDays(i); builder.append(currStart.toString("E HH:mm")); builder.append(" - "); builder.append(currEnd.toString("E HH:mm")); dayStrings.add(builder.toString()); } } return dayStrings; }
private boolean withinPeriod(Vwap vwap, DateTime quoteDate) { if (vwap == null) return false; DateTime vwapDate = vwap.getStartDate(); switch (period) { case Periodicity.MINUTELY: return ((dateOnlyComparator.compare(vwapDate, quoteDate) == 0) && vwapDate.getMinuteOfDay() == quoteDate.getMinuteOfDay()); case Periodicity.HOURLY: return ((dateOnlyComparator.compare(vwapDate, quoteDate) == 0) && vwapDate.getHourOfDay() == quoteDate.getHourOfDay()); case Periodicity.DAILY: return (dateOnlyComparator.compare(vwapDate, quoteDate) == 0); case Periodicity.WEEKLY: return (vwapDate.getYear() == quoteDate.getYear() && vwapDate.getWeekOfWeekyear() == quoteDate.getWeekOfWeekyear()); case Periodicity.MONTHLY: return (vwapDate.getYear() == quoteDate.getYear() && vwapDate.getMonthOfYear() == quoteDate.getMonthOfYear()); } return false; }
private void doCheckActualBlockingStatesToCancel(final DefaultEntitlement addOnEntitlement, final DateTime effectiveCancellationDateTime, final boolean approximateDateCheck, final Collection<BlockingState> blockingStatesForCancellation) { if (effectiveCancellationDateTime == null) { Assert.assertEquals(blockingStatesForCancellation.size(), 0); } else { Assert.assertEquals(blockingStatesForCancellation.size(), 1); final BlockingState blockingState = blockingStatesForCancellation.iterator().next(); Assert.assertEquals(blockingState.getBlockedId(), addOnEntitlement.getId()); if (approximateDateCheck) { Assert.assertEquals(blockingState.getEffectiveDate().toLocalDate(), effectiveCancellationDateTime.toLocalDate()); Assert.assertEquals(blockingState.getEffectiveDate().getMinuteOfDay(), effectiveCancellationDateTime.getMinuteOfDay()); } else { Assert.assertEquals(blockingState.getEffectiveDate(), effectiveCancellationDateTime); } Assert.assertEquals(blockingState.getType(), BlockingStateType.SUBSCRIPTION); Assert.assertEquals(blockingState.getService(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); Assert.assertEquals(blockingState.getStateName(), DefaultEntitlementApi.ENT_STATE_CANCELLED); } }
List<long[]> days = accumulateDayCounts(minuteCountsByDay, start, end, 60 * 24); counts = MetricUtils.concatArrays(days, interval.getStart().getMinuteOfDay(), interval.toPeriod().toStandardMinutes().getMinutes() + 1);
List<long[]> days = accumulateDayCounts(minuteCountsByDay, start, end, 60 * 24); counts = MetricUtils.concatArrays(days, interval.getStart().getMinuteOfDay(), interval.toPeriod().toStandardMinutes().getMinutes() + 1);
DateTime now = new DateTime(); photo.setFilename("mylovelypic_" + now.getYear() + now.getMonthOfYear() + now.getDayOfMonth() + now.getHourOfDay() + now.getMinuteOfDay() + now.getSecondOfMinute() + ".png"); photo.setBase64RawContent(base64Image.split(",")[1]); photo.setBase64RawThumbnail(base64Thumbnail.split(",")[1]);
DateTime now = new DateTime(); photo.setFilename("mylovelypic_" + now.getYear() + now.getMonthOfYear() + now.getDayOfMonth() + now.getHourOfDay() + now.getMinuteOfDay() + now.getSecondOfMinute() + ".png"); photo.setBase64RawContent(base64Image.split(",")[1]); photo.setBase64RawThumbnail(base64Thumbnail.split(",")[1]);