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:net.chaosserver.timelord.swingui.ChartingPanel.java
/** * Creates the dataset to be charted./* w w w . ja va 2 s .co m*/ * * @return the dataset to be charted. */ private CategoryDataset createDataset() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Calendar calendar = Calendar.getInstance(); DateUtil.trunc(calendar); calendar.add(Calendar.DATE, -FIRST_DATE); String series1 = "Total Hours"; for (int i = 0; i < FIRST_DATE; i++) { if (Calendar.SATURDAY != calendar.get(Calendar.DAY_OF_WEEK) && Calendar.SUNDAY != calendar.get(Calendar.DAY_OF_WEEK)) { TimelordDayView timelordDayView = new TimelordDayView(timelordData, calendar.getTime()); double totalTime = timelordDayView.getTotalTimeToday(false); if (log.isTraceEnabled()) { log.trace("Creating Value of totalTime [" + totalTime + "], series1 = " + series1 + " category [" + calendar.getTime() + "]"); } dataset.addValue(totalTime, series1, calendar.getTime()); timelordDayView.dispose(); } calendar.add(Calendar.DATE, 1); } return dataset; }
From source file:com.discovery.darchrow.date.DateExtensionUtil.java
/** * 0:00:00?0:00:00,?,between ... and ... * //w w w. j ava 2s . com * <pre> * 2012-10-16 22:18:34 * * return {2012-10-16 00:00:00.000,2012-10-17 00:00:00.000} * </pre> * * @return Date today tomorrow * @since 1.0 * @deprecated ???? */ @Deprecated public static Date[] getExtentToday() { Calendar calendar = CalendarUtil.resetCalendarByDay(new Date()); Date today = calendar.getTime(); // *************************** calendar.add(Calendar.DATE, 1); Date tomorrow = calendar.getTime(); return new Date[] { today, tomorrow }; }
From source file:com.reizes.shiva.utils.CommonUtil.java
/** * ? ? ./*from w ww . j a va2 s . c o m*/ */ public static Date getPlus1Day(Date date) { if (date == null) { return null; } Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.DATE, 1); return cal.getTime(); }
From source file:com.greenline.guahao.web.module.home.controllers.mobile.order.MobileOrderController.java
/** * html5??/*from ww w . j a va2s . c o m*/ * * @param model * @param pageSize * @param pageNo * @return String */ @MethodRemark(value = "remark=html5??,method=get") @RequestMapping(value = MobileConstants.M_ORDER_LIST_PATH, method = RequestMethod.GET) public String orderList(ModelMap model, @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize, @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo) { DomainIndexEnum domainIndex = (DomainIndexEnum) request.getAttribute(GlobalConstants.DOMAIN_ENUM); Long userId = UserCookieUtil.getUserId(request); // Calendar calendar = Calendar.getInstance(); // ? calendar.add(Calendar.DATE, 1); Date end = calendar.getTime(); // 3? calendar.add(Calendar.DAY_OF_MONTH, -92); Date begin = calendar.getTime(); LocalPageModel<OrderDO> pageModel = null; if (DomainIndexEnum.SHDISHI.equals(domainIndex) || DomainIndexEnum.BJ307.equals(domainIndex) || DomainIndexEnum.WHTONGJI.equals(domainIndex)) { pageModel = orderManager.listHospitalOrderForPageQuery(userId + StringUtils.EMPTY, null, pageSize, pageNo, begin, end); } else { pageModel = orderManager.listOrderForPageQuery(userId + StringUtils.EMPTY, null, pageSize, pageNo, begin, end); } List<OrderDO> orderDoList = pageModel.getList(); // ??? List<MobileOrderVO> orderList = new ArrayList<MobileOrderVO>(); if (null != orderDoList && !orderDoList.isEmpty()) { orderList = this.convertDOList2VOList(orderDoList); } Integer totalCount = pageModel.getTotalCount(); model.put("orderList", orderList); model.put("totalCount", totalCount); model.put("pageNo", pageModel.getPageNo()); model.put("pageSize", pageModel.getPageSize()); // ?? model.put("curr", new Date()); CommonUtils.putStaticObjToModelMap(model, OrderQueryDTO.class); model.put("currUrl", PageUtils.getCurrUrl(request)); return MobileConstants.M_ORDER_LIST; }
From source file:com.glaf.core.util.DateUtils.java
/** * ?/*w ww . j a v a 2 s . c o m*/ * * @param date * @param day * @return */ public static Date getDateAfter(Date date, int day) { Calendar now = Calendar.getInstance(); now.setTime(date); now.set(Calendar.DATE, now.get(Calendar.DATE) + day); return now.getTime(); }
From source file:ch.algotrader.service.CalendarServiceImpl.java
/** * {@inheritDoc}// w ww . j a va 2s. c om */ @Override public Date getCurrentTradingDate(final long exchangeId, final Date dateTime) { Validate.notNull(dateTime, "Data time is null"); Exchange exchange = this.exchangeDao.get(exchangeId); Validate.notNull(exchange, "exchange not found"); Date date = DateUtils.addDays(DateUtils.truncate(dateTime, Calendar.DATE), 2); NavigableSet<Date> openTimes = new TreeSet<>(); while ((openTimes.floor(dateTime)) == null) { date = DateUtils.addDays(date, -1); openTimes.addAll(getOpenTimes(exchange, date)); } return date; }
From source file:cn.mypandora.util.MyDateUtils.java
/** * ?/*from w w w .j a v a 2s. c o m*/ * * @return */ public static String getPreviousMonthEnd() { Calendar cal = Calendar.getInstance(); Calendar f = (Calendar) cal.clone(); f.clear(); // // f.set(Calendar.YEAR, cal.get(Calendar.YEAR)); // f.set(Calendar.MONTH, cal.get(Calendar.MONTH)); // f.set(Calendar.MILLISECOND, -1); // return DateFormatUtils.format(f, DATE_FORMAT); // // f.set(Calendar.YEAR, cal.get(Calendar.YEAR)); // f.set(Calendar.MONTH, cal.get(Calendar.MONTH) - 1); // f.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DATE)); // return DateFormatUtils.format(f, DATE_FORMAT); // (?) cal.set(Calendar.DATE, 1);// ?1? cal.add(Calendar.MONTH, 0);// cal.add(Calendar.DATE, -1);// ??? return DateFormatUtils.format(cal, DATE_FORMAT); }
From source file:hsa.awp.admingui.DummyValueCreator.java
/** * Inserts the test data./*from w w w. j a va 2 s . com*/ */ @Test @Transactional public void insertData() { logger.debug("start test insertData()"); SecurityContextHolder.getContext() .setAuthentication(new UsernamePasswordAuthenticationToken("admin", "password")); Campaign c = Campaign.getInstance(0L); c.setName("CampaignName"); campaignFacade.saveCampaign(c); logger.debug("saved campaign " + c); DrawProcedure d1 = DrawProcedure.getInstance(0L); d1.getDrawDate().roll(Calendar.DATE, 1); d1.getEndDate().roll(Calendar.DATE, 2); d1.setName("1. Losung"); campaignFacade.saveDrawProcedure(d1); logger.debug("saved drawProcedure " + d1); DrawProcedure d2 = DrawProcedure.getInstance(0L); d2.getStartDate().roll(Calendar.DATE, 2); d2.getEndDate().roll(Calendar.DATE, 4); d2.getDrawDate().roll(Calendar.DATE, 3); d2.setName("2. Losung"); campaignFacade.saveDrawProcedure(d2); logger.debug("saved drawProcedure " + d2); FifoProcedure f1 = FifoProcedure.getInstance(0L); Calendar f1Start = Calendar.getInstance(); f1Start.roll(Calendar.DATE, 4); Calendar f1End = Calendar.getInstance(); f1End.roll(Calendar.DATE, 5); f1.setInterval(f1Start, f1End); f1.setName("Restfifo"); campaignFacade.saveFifoProcedure(f1); logger.debug("saved fifiProcedure " + f1); c.addProcedure(f1); c.addProcedure(d1); c.addProcedure(d2); campaignFacade.updateCampaign(c); Category c1 = Category.getInstance("Testkategorie1", 0L); Category c2 = Category.getInstance("Testkategorie2", 0L); eventFacade.saveCategory(c1); eventFacade.saveCategory(c2); Subject s1 = Subject.getInstance(0L); s1.setName("TestFach"); eventFacade.saveSubject(s1); c1.addSubject(s1); eventFacade.updateSubject(s1); eventFacade.updateCategory(c1); SingleUser t1 = SingleUser.getInstance("meixner"); t1.setName("Gerhard Meixner"); RoleMapping roleMapping = RoleMapping.getInstance(Role.REGISTERED); userFacade.saveRoleMapping(roleMapping); t1.getRolemappings().add(roleMapping); userFacade.saveSingleUser(t1); Event e1 = Event.getInstance(1, 0L); e1.setMaxParticipants(20); e1.setSubject(s1); e1.getTeachers().add(t1.getId()); e1.setSubject(s1); eventFacade.saveEvent(e1); Event e2 = Event.getInstance(2, 0L); e2.setMaxParticipants(20); e2.setSubject(s1); e2.getTeachers().add(t1.getId()); e2.setSubject(s1); eventFacade.saveEvent(e2); Event e3 = Event.getInstance(3, 0L); e3.setMaxParticipants(30); e3.setSubject(s1); e3.getTeachers().add(t1.getId()); e3.setSubject(s1); eventFacade.saveEvent(e3); s1.addEvent(e1); s1.addEvent(e2); s1.addEvent(e3); eventFacade.updateSubject(s1); c.getEventIds().add(e1.getId()); campaignFacade.updateCampaign(c); PriorityList p1 = PriorityList.getInstance(0L); p1.setDate(Calendar.getInstance()); campaignFacade.savePriorityList(p1); PriorityListItem pi1 = PriorityListItem.getInstance(p1, e1.getId(), 1, 0L); PriorityListItem pi2 = PriorityListItem.getInstance(p1, e2.getId(), 2, 0L); PriorityListItem pi3 = PriorityListItem.getInstance(p1, e3.getId(), 3, 0L); campaignFacade.savePriorityListItem(pi1); campaignFacade.savePriorityListItem(pi2); campaignFacade.savePriorityListItem(pi3); p1.getItems().add(pi1); p1.getItems().add(pi2); p1.getItems().add(pi3); campaignFacade.updatePriorityList(p1); d1.getPriorityLists().add(p1); campaignFacade.updatePriorityList(p1); }
From source file:xx.tream.chengxin.ms.service.ReportServiceImpl.java
public HSSFWorkbook financialStatements(HSSFWorkbook workbook, Map<String, Object> queryMap) { HSSFSheet sheet = workbook.createSheet(""); HSSFRow headrow = sheet.createRow(0); HSSFCellStyle headcell = ExcelUtil.headCell(workbook); headrow.setRowStyle(headcell);/*w w w. j a va2s . co m*/ String start = (String) queryMap.get("beginTime"); String end = (String) queryMap.get("endTime"); Date startDate = DateUtil.stringToDate(start, "yyyy-MM-dd"); Date endDate = DateUtil.stringToDate(end, "yyyy-MM-dd"); HSSFCellStyle rightcell = ExcelUtil.rightCell(workbook); //HSSFCellStyle leftcell = ExcelUtil.leftCell(workbook); HSSFCellStyle centercell = ExcelUtil.centerCell(workbook); //? int icount = 0; if (endDate != null) { //1 Calendar cal = Calendar.getInstance(); cal.setTime(endDate); cal.add(Calendar.DATE, 1); endDate = cal.getTime(); end = DateUtil.DateToString(endDate, "yyyy-MM-dd"); queryMap.put("endTime", end); } // ExcelUtil.mergeRegion(sheet, 0, 1, 0, 0, "", headcell); sheet.setColumnWidth(0, 6500); icount++; // ExcelUtil.mergeRegion(sheet, 0, 1, 1, 1, "", headcell); sheet.setColumnWidth(1, 4500); HSSFRow row = sheet.createRow(1); icount++; int col = 2; // String[] incomeItems = ParamUtil.incomeItems; for (int i = 0; i < incomeItems.length - 1; i++) { //??? HSSFCell cell = row.createCell(col); cell.setCellValue(incomeItems[i]); cell.setCellStyle(headcell); sheet.setColumnWidth(col, 4500); col++; icount++; } String[] otherIncomeItems = reportParamService.queryIncomeOtherItem(startDate, endDate); int n = 0; if (otherIncomeItems != null && otherIncomeItems.length > 0) { for (int i = 0; i < otherIncomeItems.length; i++) { HSSFCell cell = row.createCell(col); cell.setCellValue("(" + otherIncomeItems[i] + ")"); cell.setCellStyle(headcell); sheet.setColumnWidth(col, 4500); icount++; col++; } n = otherIncomeItems.length; } int s = 2; int e = incomeItems.length + n; ExcelUtil.mergeRegion(sheet, 0, 0, s, e, "", headcell); // String[] incomeCommonItems = ParamUtil.incomeCommonItems; for (int i = 0; i < incomeCommonItems.length - 1; i++) { //??? HSSFCell cell = row.createCell(col); cell.setCellValue(incomeCommonItems[i]); cell.setCellStyle(headcell); sheet.setColumnWidth(col, 4500); col++; icount++; } String[] otherIncomeCommonItems = reportParamService.queryIncomeCommonOtherItem(startDate, endDate); n = 0; if (otherIncomeCommonItems != null && otherIncomeCommonItems.length > 0) { for (int i = 0; i < otherIncomeCommonItems.length; i++) { HSSFCell cell = row.createCell(col); cell.setCellValue("(" + otherIncomeCommonItems[i] + ")"); cell.setCellStyle(headcell); sheet.setColumnWidth(col, 4500); icount++; col++; } n = otherIncomeCommonItems.length; } s = e + 1; e = e + incomeCommonItems.length - 1 + n; ExcelUtil.mergeRegion(sheet, 0, 0, s, e, "", headcell); // n = 0; String payoutItems[] = ParamUtil.payoutItems; for (int i = 0; i < payoutItems.length - 1; i++) { //??? HSSFCell cell = row.createCell(col); cell.setCellValue(payoutItems[i]); cell.setCellStyle(headcell); sheet.setColumnWidth(col, 4500); col++; } String[] payoutOtherItems = reportParamService.queryPayoutOtherItem(startDate, endDate); if (payoutOtherItems != null && payoutOtherItems.length > 0) { for (int i = 0; i < payoutOtherItems.length; i++) { HSSFCell cell = row.createCell(col); cell.setCellValue("(" + payoutOtherItems[i] + ")"); cell.setCellStyle(headcell); sheet.setColumnWidth(col, 4500); col++; } n = payoutOtherItems.length; } s = e + 1; e = e + payoutItems.length - 1 + n; ExcelUtil.mergeRegion(sheet, 0, 0, s, e, "", headcell); // String[] payoutCommonItems = ParamUtil.payoutCommonItems; for (int i = 0; i < payoutCommonItems.length - 1; i++) { //??? HSSFCell cell = row.createCell(col); cell.setCellValue(payoutCommonItems[i]); cell.setCellStyle(headcell); sheet.setColumnWidth(col, 4500); col++; } String payoutCommonOtherTypes[] = reportParamService.queryPayoutCommonOtherItem(startDate, endDate); if (payoutCommonOtherTypes != null && payoutCommonOtherTypes.length > 0) { for (int i = 0; i < payoutCommonOtherTypes.length; i++) { HSSFCell cell = row.createCell(col); cell.setCellValue("(" + payoutCommonOtherTypes[i] + ")"); cell.setCellStyle(headcell); sheet.setColumnWidth(col, 4500); col++; } n = payoutCommonOtherTypes.length; } s = e + 1; e = e + payoutCommonItems.length - 1 + n; ExcelUtil.mergeRegion(sheet, 0, 0, s, e, "", headcell); HSSFCell cell = null; //? queryMap.put("", ""); List<Map<String, Object>> list = this.reportParamService.queryIncomeAndPayout(queryMap, incomeItems, otherIncomeItems, incomeCommonItems, otherIncomeCommonItems, payoutItems, payoutOtherItems, payoutCommonItems, payoutCommonOtherTypes); if (list != null && list.size() > 0) { double[] count = new double[col]; for (int i = 0; i < list.size(); i++) { col = 0; row = sheet.createRow(2 + i); Map<String, Object> map = list.get(i); cell = row.createCell(col); cell.setCellValue((String) map.get("audittime")); col++; cell = row.createCell(col); if (map.get("paying") != null) { Double v = (Double) map.get("paying"); count[col] = count[col] + v; cell.setCellValue(v); } col++; // if (incomeItems != null && incomeItems.length > 0) { for (int k = 0; k < incomeItems.length - 1; k++) { cell = row.createCell(col); if (map.get("i" + k) != null) { Double v = (Double) map.get("i" + k); count[col] = count[col] + v; cell.setCellValue(v); } col++; } } if (otherIncomeItems != null && otherIncomeItems.length > 0) { for (int k = 0; k < otherIncomeItems.length; k++) { cell = row.createCell(col); if (map.get("io" + k) != null) { Double v = (Double) map.get("io" + k); count[col] = count[col] + v; cell.setCellValue(v); } col++; } } // if (incomeCommonItems != null && incomeCommonItems.length > 0) { for (int k = 0; k < incomeCommonItems.length - 1; k++) { cell = row.createCell(col); if (map.get("ic" + k) != null) { Double v = (Double) map.get("ic" + k); count[col] = count[col] + v; cell.setCellValue(v); } col++; } } if (otherIncomeCommonItems != null && otherIncomeCommonItems.length > 0) { for (int k = 0; k < otherIncomeCommonItems.length; k++) { cell = row.createCell(col); if (map.get("ico" + k) != null) { Double v = (Double) map.get("ico" + k); count[col] = count[col] + v; cell.setCellValue(v); } col++; } } // if (payoutItems != null && payoutItems.length > 0) { for (int k = 0; k < payoutItems.length - 1; k++) { cell = row.createCell(col); if (map.get("p" + k) != null) { Double v = (Double) map.get("p" + k); count[col] = count[col] + v; cell.setCellValue(v); } col++; } } if (payoutOtherItems != null && payoutOtherItems.length > 0) { for (int k = 0; k < payoutOtherItems.length; k++) { cell = row.createCell(col); if (map.get("po" + k) != null) { Double v = (Double) map.get("po" + k); count[col] = count[col] + v; cell.setCellValue(v); } col++; } } // if (payoutCommonItems != null && payoutCommonItems.length > 0) { for (int k = 0; k < payoutCommonItems.length - 1; k++) { cell = row.createCell(col); if (map.get("pc" + k) != null) { Double v = (Double) map.get("pc" + k); count[col] = count[col] + v; cell.setCellValue(v); } col++; } } if (payoutCommonOtherTypes != null && payoutCommonOtherTypes.length > 0) { for (int k = 0; k < payoutCommonOtherTypes.length; k++) { cell = row.createCell(col); if (map.get("pco" + k) != null) { Double v = (Double) map.get("pco" + k); count[col] = count[col] + v; cell.setCellValue(v); } col++; } } } //? row = sheet.createRow(2 + list.size()); cell = null; for (int i = 0; i < count.length; i++) { if (i == 0) { cell = row.createCell(0); cell.setCellValue("?"); cell.setCellStyle(headcell); } else { cell = row.createCell(i); cell.setCellValue(count[i]); } } double ivalue = 0; double pvalue = 0; for (int i = 0; i < icount; i++) { ivalue += count[i]; } for (int i = icount; i < count.length; i++) { pvalue += count[i]; } // row = sheet.createRow(3 + list.size()); cell = row.createCell(0); cell.setCellValue(":"); cell.setCellStyle(headcell); cell = row.createCell(1); cell.setCellValue(ivalue); cell = row.createCell(2); cell.setCellValue(":"); cell.setCellStyle(headcell); cell = row.createCell(3); cell.setCellValue(pvalue); } int rowNum = 0; // List<Map<String, Object>> trainIPOList = this.queryTrainIncomePayout(queryMap); if (trainIPOList != null && trainIPOList.size() > 0) { sheet = workbook.createSheet(""); String heads[] = { "", "?", "", "", "", "", "" }; String values[] = { "name", "idcard", "payable", "allincome", "allpaying", "allpayout" }; row = sheet.createRow(rowNum); for (int i = 0; i < heads.length; i++) { cell = row.createCell(i); cell.setCellValue(heads[i]); cell.setCellStyle(headcell); sheet.setColumnWidth(i, 4500); } rowNum++; double countAll[] = new double[heads.length]; for (int i = 0; i < trainIPOList.size(); i++) { row = sheet.createRow(rowNum); Map<String, Object> map = trainIPOList.get(i); // double allpip = 0; for (int k = 0; k < values.length; k++) { cell = row.createCell(k); if (map.get(values[k]) != null) { if (k > 1) { double value = (Double) map.get(values[k]); if (k < 4) { allpip += value; } cell.setCellValue(value); countAll[k] += value; } else { cell.setCellValue((String) map.get(values[k])); } } } // cell = row.createCell(values.length); cell.setCellValue(allpip); countAll[values.length] += allpip; rowNum++; } //? row = sheet.createRow(rowNum); cell = row.createCell(0); cell.setCellValue("?"); cell.setCellStyle(headcell); for (int i = 2; i < countAll.length; i++) { cell = row.createCell(i); cell.setCellValue(countAll[i]); } rowNum++; } rowNum = 0; // List<Map<String, Object>> countList = this.queryCountByTime(queryMap); if (countList != null && countList.size() > 0) { sheet = workbook.createSheet(""); String heads[] = { "", "?", "?", "?", "?", "?", "?", "???" }; String values[] = { "audittime", "payable", "paying", "income", "incomeCommon", "payout", "payoutCommon", "canPay" }; row = sheet.createRow(rowNum); for (int i = 0; i < heads.length; i++) { cell = row.createCell(i); cell.setCellValue(heads[i]); cell.setCellStyle(headcell); sheet.setColumnWidth(i, 4500); } rowNum++; double countAll[] = new double[heads.length]; for (int i = 0; i < countList.size(); i++) { row = sheet.createRow(rowNum); Map<String, Object> map = countList.get(i); for (int k = 0; k < values.length; k++) { cell = row.createCell(k); if (map.get(values[k]) != null) { if (k > 0) { double value = (Double) map.get(values[k]); cell.setCellValue(value); cell.setCellStyle(rightcell); countAll[k] += value; } else { cell.setCellValue((String) map.get(values[k])); cell.setCellStyle(centercell); } } } rowNum++; } //? row = sheet.createRow(rowNum); cell = row.createCell(0); cell.setCellValue("?"); cell.setCellStyle(headcell); for (int i = 1; i < countAll.length; i++) { cell = row.createCell(i); cell.setCellValue(countAll[i]); if (countAll[i] >= 0) { cell.setCellStyle(rightcell); } else { } } rowNum++; } return workbook; }
From source file:com.hangame.tera.action.event.TeraAttendenceLondonEventAction.java
/** * ? ? ??? /*from w w w . j ava2 s. com*/ * * @param listDays ? ? * @param mapDays ? * @return ??? */ private int setMapDays(List<DataMap> listDays, LinkedHashMap<Integer, Integer> mapDays) { int allPoint = 0; Calendar cal = Calendar.getInstance(); cal.set(2012, 6, 25); //?? for (int i = 0; i < 22; i++) { //? 22? cal.add(Calendar.DATE, 1); int day = cal.get(Calendar.DATE); boolean isEmpty = true; for (int k = 0, size = listDays.size(); k < size; k++) { DataMap dmap = listDays.get(k); String addInfo = dmap.getString("add_info", ""); if (NumberUtils.toInt(addInfo.substring(6, 8)) == day) { int point = dmap.getInt("point", 0); allPoint += point; mapDays.put(day, point); listDays.remove(k); isEmpty = false; break; } } if (isEmpty) { mapDays.put(day, 0); } } return allPoint; }