List of usage examples for org.joda.time MutableDateTime setMillisOfDay
public void setMillisOfDay(final int millisOfDay)
From source file:ke.co.tawi.babblesms.server.session.SessionStatisticsFactory.java
License:Open Source License
/** * * @param accountUuid/*from www .j a v a2s . co m*/ * @return session statistics */ public static SessionStatistics getSessionStatistics(String accountUuid) { int count; //int[] arraycount = new int[2]; SessionStatistics stats = new SessionStatistics(); // Get the list of all networks List<Network> networkList = networkDAO.getAllNetworks(); ; //set the count of all incoming SMS stats.setAllIncomingSMSCount(countUtils.getIncomingCount(accountUuid)); //set the count of all outgoing SMS stats.setAllOutgoingSMSCount(countUtils.getOutgoingLog(accountUuid)); //set the count of all outgoing Group SMS //stats.setAllOutgoingSMSCount(countUtils.getOutgoingGroupLog(accountUuid)); // Set up data for the pie charts for (Network network : networkList) { //get the count of incoming SMS according to the account and network count = countUtils.getIncomingCount(accountUuid, network); //if count is greater than zero, add the information if (count > 0) { stats.addNetworkIncomingCount(network, count); } //get the count of outgoing SMS according to the account and network count = countUtils.getOutgoingCount(accountUuid, network); //if count is greater than zero, add the information if (count > 0) { stats.addNetworkOutgoingSMSCount(network, count); } } // Set up data for the bar charts DateTime dateMidnightStart = DateTime.now().minus(Hours.hours(24 * (IncomingBarDay.DAY_COUNT))); DateTime dateMidnightEnd = dateMidnightStart.plus(Hours.hours(24)); int numDays = 0; do { for (Network network : networkList) { //get the daily count for incoming count = countUtils.getIncomingCount(accountUuid, network, new Date(dateMidnightStart.getMillis()), new Date(dateMidnightEnd.getMillis())); if (count > 0) { stats.addNetworkIncomingUSSDCountDay( new SimpleDateFormat("MMM d").format(new Date(dateMidnightStart.getMillis())), network, count); } //get the daily count for outgoing count = countUtils.getOutgoingCount(accountUuid, network, new Date(dateMidnightStart.getMillis()), new Date(dateMidnightEnd.getMillis())); if (count > 0) { stats.addNetworkOutgoingUSSDCountDay( new SimpleDateFormat("MMM d").format(new Date(dateMidnightStart.getMillis())), network, count); } } dateMidnightStart = dateMidnightStart.plus(Hours.hours(24)); dateMidnightEnd = dateMidnightEnd.plus(Hours.hours(24)); numDays++; } while (numDays < IncomingBarDay.DAY_COUNT); // Set up data for the Weekly bar charts int numWeeks = 0; MutableDateTime startwkMutableDateTime = new MutableDateTime(); MutableDateTime endwkMutableDateTime; startwkMutableDateTime.setDayOfWeek(1); //get the first day of the week startwkMutableDateTime.setMillisOfDay(0); //get 00:00:00 time of the day //go back to 7 weeks startwkMutableDateTime.addWeeks(-7); do { // set the end date by creating a copy endwkMutableDateTime = new MutableDateTime(startwkMutableDateTime); //push it by one week endwkMutableDateTime.addWeeks(1); for (Network network : networkList) { //get the Weekly count for Incoming USSD count = countUtils.getIncomingCount(accountUuid, network, new Date(startwkMutableDateTime.toDate().getTime()), new Date(endwkMutableDateTime.toDate().getTime())); if (count > 0) { stats.addNetworkIncomingUSSDCountWeek( new SimpleDateFormat("MMM d").format(new Date(startwkMutableDateTime.getMillis())), network, count); } //get the Weekly count for Outgoing USSD count = countUtils.getOutgoingCount(accountUuid, network, new Date(startwkMutableDateTime.toDate().getTime()), new Date(endwkMutableDateTime.toDate().getTime())); if (count > 0) { stats.addNetworkOutgoingUSSDCountWeek( new SimpleDateFormat("MMM d").format(new Date(startwkMutableDateTime.getMillis())), network, count); } } // get the next week startwkMutableDateTime.addWeeks(1); numWeeks++; } while (numWeeks < 7); // Set up data for the monthly bar charts int numMonths = 0; MutableDateTime startMutableDateTime = new MutableDateTime(); MutableDateTime endMutableDateTime; startMutableDateTime.setDayOfMonth(1); //get the first day of the month startMutableDateTime.setMillisOfDay(0); //get 00:00:00 time of the day //go back to 6 months startMutableDateTime.addMonths(-5); do { //set the end date by creating a copy endMutableDateTime = new MutableDateTime(startMutableDateTime); //push it by one month endMutableDateTime.addMonths(1); //System.out.println("Start date: " + startMutableDateTime); //System.out.println("End date: " + endMutableDateTime); for (Network network : networkList) { //change to use millis count = countUtils.getIncomingCount(accountUuid, network, new Date(startMutableDateTime.toDate().getTime()), new Date(endMutableDateTime.toDate().getTime())); if (count > 0) { stats.addNetworkIncomingUSSDCountMonth( new SimpleDateFormat("MMM").format(new Date(startMutableDateTime.getMillis())), network, count); } //System.out.println(count); } //get the next month startMutableDateTime.addMonths(1); numMonths++; } while (numMonths < 6); return stats; }
From source file:org.apache.druid.server.log.FileRequestLogger.java
License:Apache License
@LifecycleStart @Override//from w w w .j a va 2 s. c o m public void start() { try { baseDir.mkdirs(); MutableDateTime mutableDateTime = DateTimes.nowUtc().toMutableDateTime(ISOChronology.getInstanceUTC()); mutableDateTime.setMillisOfDay(0); synchronized (lock) { currentDay = mutableDateTime.toDateTime(ISOChronology.getInstanceUTC()); fileWriter = getFileWriter(); } long nextDay = currentDay.plusDays(1).getMillis(); Duration initialDelay = new Duration(nextDay - System.currentTimeMillis()); ScheduledExecutors.scheduleWithFixedDelay(exec, initialDelay, Duration.standardDays(1), new Callable<ScheduledExecutors.Signal>() { @Override public ScheduledExecutors.Signal call() { try { synchronized (lock) { currentDay = currentDay.plusDays(1); CloseQuietly.close(fileWriter); fileWriter = getFileWriter(); } } catch (Exception e) { throw new RuntimeException(e); } return ScheduledExecutors.Signal.REPEAT; } }); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:org.gdg.frisbee.android.eventseries.EventListFragment.java
License:Apache License
private DateTime getMonthStart(int month) { MutableDateTime date = new MutableDateTime(); date.setDayOfMonth(1);/* w w w . ja v a 2s .co m*/ date.setMillisOfDay(0); date.setMonthOfYear(month); return date.toDateTime(); }
From source file:org.gdg.frisbee.android.eventseries.EventListFragment.java
License:Apache License
private DateTime getMonthEnd(int month) { MutableDateTime date = MutableDateTime.now(); date.setMillisOfDay(0); date.setMonthOfYear(month);/* ww w . j a v a 2s . c o m*/ return date.toDateTime().dayOfMonth().withMaximumValue().millisOfDay().withMaximumValue(); }
From source file:org.kuali.rice.kew.docsearch.DocumentSearchInternalUtils.java
License:Educational Community License
public static DateTime getLowerDateTimeBound(String dateRange) throws ParseException { Range range = SearchExpressionUtils.parseRange(dateRange); if (range == null) { throw new IllegalArgumentException("Failed to parse date range from given string: " + dateRange); }/* w w w . j a va2 s . co m*/ if (range.getLowerBoundValue() != null) { java.util.Date lowerRangeDate = null; try { lowerRangeDate = CoreApiServiceLocator.getDateTimeService() .convertToDate(range.getLowerBoundValue()); } catch (ParseException pe) { GlobalVariables.getMessageMap().putError("dateFrom", RiceKeyConstants.ERROR_CUSTOM, pe.getMessage()); } MutableDateTime dateTime = new MutableDateTime(lowerRangeDate); dateTime.setMillisOfDay(0); return dateTime.toDateTime(); } return null; }
From source file:org.kuali.rice.kew.docsearch.DocumentSearchInternalUtils.java
License:Educational Community License
public static DateTime getUpperDateTimeBound(String dateRange) throws ParseException { Range range = SearchExpressionUtils.parseRange(dateRange); if (range == null) { throw new IllegalArgumentException("Failed to parse date range from given string: " + dateRange); }// w w w . j a v a 2 s . c o m if (range.getUpperBoundValue() != null) { java.util.Date upperRangeDate = null; try { upperRangeDate = CoreApiServiceLocator.getDateTimeService() .convertToDate(range.getUpperBoundValue()); } catch (ParseException pe) { GlobalVariables.getMessageMap().putError("dateCreated", RiceKeyConstants.ERROR_CUSTOM, pe.getMessage()); } MutableDateTime dateTime = new MutableDateTime(upperRangeDate); // set it to the last millisecond of the day dateTime.setMillisOfDay((24 * 60 * 60 * 1000) - 1); return dateTime.toDateTime(); } return null; }