List of usage examples for java.util Calendar DATE
int DATE
To view the source code for java.util Calendar DATE.
Click Source Link
get
and set
indicating the day of the month. From source file:org.projectforge.plugins.liquidityplanning.LiquidityChartBuilder.java
/** * @param forecast/*from ww w.java2 s . c o m*/ * @param settings (next days) * @return */ public JFreeChart createXYPlot(final LiquidityForecast forecast, final LiquidityForecastSettings settings) { Validate.isTrue(settings.getNextDays() > 0 && settings.getNextDays() < 500); final LiquidityForecastCashFlow cashFlow = new LiquidityForecastCashFlow(forecast, settings.getNextDays()); final TimeSeries accumulatedSeries = new TimeSeries( I18n.getString("plugins.liquidityplanning.forecast.dueDate")); final TimeSeries accumulatedSeriesExpected = new TimeSeries( ThreadLocalUserContext.getLocalizedString("plugins.liquidityplanning.forecast.expected")); final TimeSeries worstCaseSeries = new TimeSeries( I18n.getString("plugins.liquidityplanning.forecast.worstCase")); double accumulatedExpected = settings.getStartAmount().doubleValue(); double accumulated = accumulatedExpected; double worstCase = accumulated; final DayHolder dh = new DayHolder(); final Date lower = dh.getDate(); for (int i = 0; i < settings.getNextDays(); i++) { if (log.isDebugEnabled() == true) { log.debug("day: " + i + ", credits=" + cashFlow.getCredits()[i] + ", debits=" + cashFlow.getDebits()[i]); } final Day day = new Day(dh.getDayOfMonth(), dh.getMonth() + 1, dh.getYear()); if (i > 0) { accumulated += cashFlow.getDebits()[i - 1].doubleValue() + cashFlow.getCredits()[i - 1].doubleValue(); accumulatedExpected += cashFlow.getDebitsExpected()[i - 1].doubleValue() + cashFlow.getCreditsExpected()[i - 1].doubleValue(); worstCase += cashFlow.getCredits()[i - 1].doubleValue(); } accumulatedSeries.add(day, accumulated); accumulatedSeriesExpected.add(day, accumulatedExpected); worstCaseSeries.add(day, worstCase); dh.add(Calendar.DATE, 1); } dh.add(Calendar.DATE, -1); final XYChartBuilder cb = new XYChartBuilder(null, null, null, null, true); int counter = 0; final TimeSeriesCollection xyDataSeries = new TimeSeriesCollection(); xyDataSeries.addSeries(accumulatedSeries); xyDataSeries.addSeries(worstCaseSeries); final XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(true, false); lineRenderer.setSeriesPaint(0, Color.BLACK); lineRenderer.setSeriesVisibleInLegend(0, true); lineRenderer.setSeriesPaint(1, cb.getGrayMarker()); lineRenderer.setSeriesStroke(1, cb.getDashedStroke()); lineRenderer.setSeriesVisibleInLegend(1, true); cb.setRenderer(counter, lineRenderer).setDataset(counter++, xyDataSeries); final TimeSeriesCollection accumulatedSet = new TimeSeriesCollection(); accumulatedSet.addSeries(accumulatedSeriesExpected); final XYDifferenceRenderer diffRenderer = new XYDifferenceRenderer(cb.getGreenFill(), cb.getRedFill(), true); diffRenderer.setSeriesPaint(0, cb.getRedMarker()); cb.setRenderer(counter, diffRenderer).setDataset(counter++, accumulatedSet).setStrongStyle(diffRenderer, false, accumulatedSeriesExpected); diffRenderer.setSeriesVisibleInLegend(0, true); cb.setDateXAxis(true).setDateXAxisRange(lower, dh.getDate()).setYAxis(true, null); return cb.getChart(); }
From source file:net.ontopia.Ontopia.java
/** * PUBLIC: Returns a formatted string with product the build date * and build user.//w ww. j a v a2 s . c om */ public static String getBuild() { int year = getBuildDate().get(Calendar.YEAR); int month = getBuildDate().get(Calendar.MONTH) + 1; int day = getBuildDate().get(Calendar.DATE); int hour = getBuildDate().get(Calendar.HOUR_OF_DAY); int minute = getBuildDate().get(Calendar.MINUTE); String user = getBuildUser(); return year + "-" + (month < 10 ? "0" + month : String.valueOf(month)) + "-" + (day < 10 ? "0" + day : String.valueOf(day)) + " " + (hour < 10 ? "0" + hour : String.valueOf(hour)) + ":" + (minute < 10 ? "0" + minute : String.valueOf(minute)) + (user == null ? "" : " by " + getBuildUser()); }
From source file:org.openmrs.module.reportingdemo.definition.dataset.evaluator.EncounterBreakdownDataSetEvaluator.java
/** * @throws EvaluationException //www . j av a 2s .c o m * @see DataSetEvaluator#evaluate(DataSetDefinition, EvaluationContext) */ public DataSet evaluate(DataSetDefinition dataSetDefinition, EvaluationContext context) throws EvaluationException { context = ObjectUtil.nvl(context, new EvaluationContext()); MapDataSet data = new MapDataSet(dataSetDefinition, context); EncounterBreakdownDataSetDefinition dsd = (EncounterBreakdownDataSetDefinition) dataSetDefinition; // Construct the encounter filters to iterate across Map<String, List<EncounterType>> encounterTypeFilters = new LinkedHashMap<String, List<EncounterType>>(); List<EncounterType> otherEncounterTypes = Context.getEncounterService().getAllEncounterTypes(); for (int encTypeNum = 1; encTypeNum <= dsd.getTypes().size(); encTypeNum++) { EncounterType encounterType = dsd.getTypes().get(encTypeNum - 1); encounterTypeFilters.put("enc" + encTypeNum, Arrays.asList(encounterType)); otherEncounterTypes.remove(encounterType); } encounterTypeFilters.put("otherenc", otherEncounterTypes); // Construct the user and location filters to iterate across Map<String, List<User>> userFilters = new LinkedHashMap<String, List<User>>(); Map<String, List<Location>> locationFilters = new LinkedHashMap<String, List<Location>>(); if (dsd.getGrouping() == EncounterBreakdownDataSetDefinition.Grouping.User) { // Determine what users to iterate across. Default to top 10, and "other" List<User> mostFrequentUsers = getUsersOrderedByNumEncounters( DateUtil.adjustDate(dsd.getEndDate(), -7 * dsd.getNumberOfWeeks(), Calendar.DATE), dsd.getEndDate(), context); List<User> otherUsers = Context.getUserService().getAllUsers(); for (int userNum = 1; userNum <= mostFrequentUsers.size() && userNum <= 10; userNum++) { User user = mostFrequentUsers.get(userNum - 1); String userKey = "user" + userNum; userFilters.put(userKey, Arrays.asList(user)); otherUsers.remove(user); data.addData(new DataSetColumn(userKey + "name", userKey + "name", String.class), user.getUsername()); } userFilters.put("userother", otherUsers); } else { List<Location> locations = Context.getLocationService().getAllLocations(); for (int locationNum = 1; locationNum <= locations.size(); locationNum++) { Location location = locations.get(locationNum - 1); String locationKey = "loc" + locationNum; locationFilters.put(locationKey, Arrays.asList(location)); data.addData(new DataSetColumn(locationKey + "name", locationKey + "name", String.class), location.getName()); } } // Now, iterate across the product of all of these and add them to the data set Date startDate, endDate = null; for (int weekNum = 0; weekNum < dsd.getNumberOfWeeks(); weekNum++) { endDate = (endDate == null ? dsd.getEndDate() : DateUtil.adjustDate(endDate, -7, Calendar.DATE)); startDate = DateUtil.adjustDate(endDate, -6, Calendar.DATE); for (String encounterTypeKey : encounterTypeFilters.keySet()) { List<EncounterType> encounterTypes = encounterTypeFilters.get(encounterTypeKey); for (String userKey : userFilters.keySet()) { List<User> users = userFilters.get(userKey); String key = userKey + encounterTypeKey + "ago" + weekNum; addData(data, key, startDate, endDate, encounterTypes, users, null, context); } for (String locationKey : locationFilters.keySet()) { List<Location> locations = locationFilters.get(locationKey); String key = locationKey + encounterTypeKey + "ago" + weekNum; addData(data, key, startDate, endDate, encounterTypes, null, locations, context); } } } return data; }
From source file:com.example.android.directboot.alarms.Alarm.java
@Override public int compareTo(@NonNull Alarm other) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MONTH, month); calendar.set(Calendar.DATE, date); calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minute); Calendar otherCal = Calendar.getInstance(); otherCal.set(Calendar.MONTH, other.month); otherCal.set(Calendar.DATE, other.date); otherCal.set(Calendar.HOUR_OF_DAY, other.hour); otherCal.set(Calendar.MINUTE, other.minute); return calendar.compareTo(otherCal); }
From source file:com.intuit.wasabi.tests.service.CountDailyIntegrationTest.java
/** * Initializes a default experiment.//from w w w. java 2 s.c om */ public CountDailyIntegrationTest() { setResponseLogLengthLimit(1000); dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, -1); yesterday = dateFormat.format(cal.getTime()); yesterday += "T00:00:00+0000"; cal = Calendar.getInstance(); cal.add(Calendar.DATE, 0); today = dateFormat.format(cal.getTime()); today += "T00:00:00+0000"; cal = Calendar.getInstance(); cal.add(Calendar.DATE, 1); tomorrow = dateFormat.format(cal.getTime()); tomorrow += "T00:00:00+0000"; cal = Calendar.getInstance(); cal.add(Calendar.DATE, 4); tomorrowPlus3 = dateFormat.format(cal.getTime()); tomorrowPlus3 += "T00:00:00+0000"; experiment = ExperimentFactory.createExperiment(); experiment.startTime = yesterday; experiment.endTime = tomorrowPlus3; experiment.samplingPercent = 1.0; experiment.label = "experiment"; experiment.applicationName = QBO + UUID.randomUUID(); DefaultNameExclusionStrategy experimentComparisonStrategy = new DefaultNameExclusionStrategy("creationTime", "modificationTime", "ruleJson"); experiment.setSerializationStrategy(experimentComparisonStrategy); }
From source file:io.lavagna.service.StatisticsServiceTest.java
@Before public void prepare() { Helper.createUser(userRepository, "test", "test-user"); user = userRepository.findUserByName("test", "test-user"); Project p = projectService.create("test", "TEST", "desc"); board = boardRepository.createNewBoard("test-board", "TEST-BRD", null, p.getId()); List<BoardColumnDefinition> definitions = projectService .findColumnDefinitionsByProjectId(projectService.findByShortName("TEST").getId()); for (BoardColumnDefinition def : definitions) { if (def.getValue() == ColumnDefinition.OPEN) { openCol = boardColumnRepository.addColumnToBoard("col1", def.getId(), BoardColumn.BoardColumnLocation.BOARD, board.getId()); }//from w w w.j a v a 2 s . c om } today = DateUtils.truncate(new Date(), Calendar.DATE); yesterday = DateUtils.addDays(today, -1); oneMonthAgo = DateUtils.addMonths(today, -1); lastSnapshot = DateUtils.addYears(today, -10); card = cardService.createCard("card1", openCol.getId(), today, user); assigned = cardLabelRepository.findLabelByName(p.getId(), "ASSIGNED", CardLabel.LabelDomain.SYSTEM); customLabel = cardLabelRepository.addLabel(p.getId(), true, CardLabel.LabelType.USER, CardLabel.LabelDomain.USER, "Custom label", 0); labelValueToUser = new CardLabelValue.LabelValue(null, null, null, null, user.getId(), null); }
From source file:org.kuali.mobility.sakai.controllers.SakaiController.java
@RequestMapping(method = RequestMethod.GET) public String getSites(HttpServletRequest request, @RequestParam(value = "date", required = false) String date, Model uiModel) {/* w ww . jav a 2 s .c o m*/ User user = (User) request.getSession().getAttribute(Constants.KME_USER_KEY); Home home = sakaiSiteService.findSakaiHome(user.getUserId(), date); uiModel.addAttribute("home", home); uiModel.addAttribute("tabCount", (home.getCourses() != null && home.getCourses().size() > 0 ? 2 : 0) + (home.getProjects() != null && home.getProjects().size() > 0 ? 1 : 0) + (home.getOther() != null && home.getOther().size() > 0 ? 1 : 0)); Calendar todayDate = Calendar.getInstance(); if (date != null) { try { todayDate.setTime(Constants.DateFormat.queryStringDateFormat.getFormat().parse(date)); } catch (Exception e) { } } todayDate.set(Calendar.HOUR, 0); todayDate.set(Calendar.MINUTE, 0); todayDate.set(Calendar.SECOND, 0); todayDate.set(Calendar.MILLISECOND, 0); uiModel.addAttribute("todayDisplay", Constants.DateFormat.displayDateFormat.getFormat().format(todayDate.getTime())); todayDate.add(Calendar.DATE, -1); uiModel.addAttribute("yesterday", Constants.DateFormat.queryStringDateFormat.getFormat().format(todayDate.getTime())); uiModel.addAttribute("yesterdayButton", Constants.DateFormat.buttonDateFormat.getFormat().format(todayDate.getTime())); todayDate.add(Calendar.DATE, 2); uiModel.addAttribute("tomorrow", Constants.DateFormat.queryStringDateFormat.getFormat().format(todayDate.getTime())); uiModel.addAttribute("tomorrowButton", Constants.DateFormat.buttonDateFormat.getFormat().format(todayDate.getTime())); return "sakai/home"; }
From source file:jp.co.opentone.bsol.framework.core.util.DateUtil.java
/** * ?????????./*from w ww. ja v a 2s . com*/ * @param deadline ? * @return true:? */ public static boolean isExpire(Date deadline) { if (deadline == null) { return false; } // ?+1? Calendar cal = Calendar.getInstance(); cal.setTime(deadline); cal.add(Calendar.DATE, 1); return cal.getTime().before(getNow()); }
From source file:hubert.team.paragraphs.AdvertsOverviewModel.java
public Calendar getMinDate() { final String dateParameter = MgnlContext.getParameter("date"); if (StringUtils.isNotEmpty(dateParameter)) { Date date;/*ww w . j a v a 2 s. c o m*/ try { date = new SimpleDateFormat("yyyy.MM.dd").parse(dateParameter); } catch (ParseException e) { throw new IllegalArgumentException("Can't parse date " + dateParameter); } minDate.setTimeInMillis(date.getTime()); } else { String selector = MgnlContext.getAggregationState().getSelector(); if (StringUtils.isNotEmpty(selector)) { manipulateBySelector(minDate, selector); } this.minDate.set(Calendar.DATE, minDate.getActualMinimum(Calendar.DATE)); this.minDate.set(Calendar.HOUR_OF_DAY, minDate.getActualMinimum(Calendar.HOUR_OF_DAY)); this.minDate.set(Calendar.MINUTE, minDate.getActualMinimum(Calendar.MINUTE)); // If not set the events will be shifted to the previous day on the calendar paragraph if no time has been given eg. dd.MM.yyyy 00.00.0000. this.minDate.set(Calendar.SECOND, minDate.getActualMinimum(Calendar.SECOND)); this.minDate.set(Calendar.MILLISECOND, minDate.getActualMinimum(Calendar.MILLISECOND)); } return minDate; }
From source file:org.zlogic.vogon.web.data.TransactionFilterSpecification.java
/** * Sets the date filter/*www . j a v a2 s.co m*/ * * @param filterDate the date to be filtered */ public void setFilterDate(Date filterDate) { //Convert to local time (OpenShift and other non-UTC servers workaround) if (filterDate != null) { Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); //NOI18N calendar.setTime(filterDate); Calendar newCalendar = new GregorianCalendar(); newCalendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE), 0, 0, 0); newCalendar.set(Calendar.MILLISECOND, 0); filterDate = newCalendar.getTime(); } this.filterDate = filterDate; }