List of usage examples for java.util Calendar getActualMinimum
public int getActualMinimum(int field)
Calendar
. From source file:net.groupbuy.controller.admin.PurchaseRankingController.java
/** * // w w w . j a v a2s .c o m */ @RequestMapping(value = "/list", method = RequestMethod.GET) public String list(Date beginDate, Date endDate, Integer count, Model model) { if (beginDate != null) { Calendar calendar = DateUtils.toCalendar(beginDate); calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMinimum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getActualMinimum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMinimum(Calendar.SECOND)); beginDate = calendar.getTime(); } if (endDate != null) { Calendar calendar = DateUtils.toCalendar(endDate); calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMaximum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getActualMaximum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMaximum(Calendar.SECOND)); endDate = calendar.getTime(); } if (count == null || count <= 0) { count = DEFAULT_COUNT; } model.addAttribute("beginDate", beginDate); model.addAttribute("endDate", endDate); model.addAttribute("count", count); model.addAttribute("data", memberService.findPurchaseList(beginDate, endDate, count)); return "/admin/purchase_ranking/list"; }
From source file:net.groupbuy.controller.admin.SalesRankingController.java
/** * //www . j ava 2s .co m */ @RequestMapping(value = "/list", method = RequestMethod.GET) public String list(Date beginDate, Date endDate, Integer count, Model model) { if (beginDate != null) { Calendar calendar = DateUtils.toCalendar(beginDate); calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMinimum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getActualMinimum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMinimum(Calendar.SECOND)); beginDate = calendar.getTime(); } if (endDate != null) { Calendar calendar = DateUtils.toCalendar(endDate); calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMaximum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getActualMaximum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMaximum(Calendar.SECOND)); endDate = calendar.getTime(); } if (count == null || count <= 0) { count = DEFAULT_COUNT; } model.addAttribute("beginDate", beginDate); model.addAttribute("endDate", endDate); model.addAttribute("count", count); model.addAttribute("data", productService.findSalesList(beginDate, endDate, count)); return "/admin/sales_ranking/list"; }
From source file:org.power.commons.lang.util.time.DateUtils.java
/** * #func ??<br>// w w w . j a v a 2s.c om * * @author dongguoshuang */ public static Date getFirstDayOfMonth(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); int firstDay = calendar.getActualMinimum(Calendar.DAY_OF_MONTH); return org.apache.commons.lang3.time.DateUtils.setDays(date, firstDay); }
From source file:fr.paris.lutece.plugins.form.utils.FormUtils.java
/** * return a timestamp Object which correspond with the string specified in parameter. * @param date the date who must convert * @param locale the locale//from w w w . j ava 2 s.c om * @return a timestamp Object which correspond with the string specified in parameter. */ public static Timestamp getDateFirstMinute(Date date, Locale locale) { if (date == null) { return null; } Calendar caldate = new GregorianCalendar(); caldate.setTime(date); caldate.set(Calendar.MILLISECOND, 0); caldate.set(Calendar.SECOND, 0); caldate.set(Calendar.HOUR_OF_DAY, caldate.getActualMinimum(Calendar.HOUR_OF_DAY)); caldate.set(Calendar.MINUTE, caldate.getActualMinimum(Calendar.MINUTE)); Timestamp timeStamp = new Timestamp(caldate.getTimeInMillis()); return timeStamp; }
From source file:com.lordmat.githubstream.data.GitHubCallerTest.java
@Test public void testGetCommits() { System.out.println("testGetCommits"); GitHubCaller instance = createInstance(); Calendar calender = Calendar.getInstance(); calender.set(Calendar.DATE, calender.getActualMinimum(Calendar.DATE)); String since = DateTimeFormat.format(calender.getTime()); String until = null;/*from w w w .j ava2 s. com*/ Map<Date, GitHubCommit> result = instance.getCommits(since, until); assertTrue(result.size() > 0); assertNotNull(result.values().iterator().next().getDate()); }
From source file:com.sammyun.controller.console.StaticController.java
/** * ???//from w w w . ja v a 2s.c om */ @RequestMapping(value = "/build", method = RequestMethod.POST) public @ResponseBody Map<String, Object> build(BuildType buildType, Long articleCategoryId, Long productCategoryId, Date beginDate, Date endDate, Integer first, Integer count, String lang, HttpServletRequest request, HttpServletResponse response) { long startTime = System.currentTimeMillis(); if (beginDate != null) { Calendar calendar = DateUtils.toCalendar(beginDate); calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMinimum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getActualMinimum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMinimum(Calendar.SECOND)); beginDate = calendar.getTime(); } if (endDate != null) { Calendar calendar = DateUtils.toCalendar(endDate); calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMaximum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getActualMaximum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMaximum(Calendar.SECOND)); endDate = calendar.getTime(); } if (first == null || first < 0) { first = 0; } if (count == null || count <= 0) { count = 50; } int buildCount = 0; boolean isCompleted = true; if (lang == null) { lang = "zh_CN"; } staticService.setLocale(lang); WebUtils.removeCookie(request, response, langCookieName); WebUtils.addCookie(request, response, langCookieName, lang); if (buildType == BuildType.index) { buildCount = staticService.buildIndex(); } else if (buildType == BuildType.article) { } else if (buildType == BuildType.other) { buildCount = staticService.buildOther(); } long endTime = System.currentTimeMillis(); Map<String, Object> map = new HashMap<String, Object>(); map.put("first", first); map.put("buildCount", buildCount); map.put("buildTime", endTime - startTime); map.put("isCompleted", isCompleted); return map; }
From source file:com.lohika.alp.reporter.fe.dao.TestDAOImpl.java
private DetachedCriteria getFilteredCriteria(TestFilter filter) { DetachedCriteria criteria = DetachedCriteria.forClass(Test.class); criteria.createAlias("suite", "suite"); if (filter.getFrom() != null && filter.getTill() != null) { Calendar c = Calendar.getInstance(); c.setTime(filter.getFrom());// ww w .j a v a2 s.c o m c.set(Calendar.HOUR_OF_DAY, c.getActualMinimum(Calendar.HOUR_OF_DAY)); c.set(Calendar.MINUTE, c.getActualMinimum(Calendar.MINUTE)); c.set(Calendar.SECOND, c.getActualMinimum(Calendar.SECOND)); c.set(Calendar.MILLISECOND, c.getActualMinimum(Calendar.MILLISECOND)); Date from = c.getTime(); c.setTime(filter.getTill()); c.set(Calendar.HOUR_OF_DAY, c.getActualMaximum(Calendar.HOUR_OF_DAY)); c.set(Calendar.MINUTE, c.getActualMaximum(Calendar.MINUTE)); c.set(Calendar.SECOND, c.getActualMaximum(Calendar.SECOND)); c.set(Calendar.MILLISECOND, c.getActualMaximum(Calendar.MILLISECOND)); Date till = c.getTime(); criteria.add(Restrictions.between("startDate", from, till)); } if (filter.getTest() != "" && filter.getTest() != null) { try { criteria.add(querytr.translate("name", filter.getTest())); } catch (QueryTranslatorException e) { // TODO Put QueryTranslatorException into log e.printStackTrace(); } } if (filter.getSuite() != "" && filter.getSuite() != null) { try { criteria.add(querytr.translate("suite.name", filter.getSuite())); } catch (QueryTranslatorException e) { // TODO Put QueryTranslatorException into log e.printStackTrace(); } } return criteria; }
From source file:net.groupbuy.controller.admin.StaticController.java
/** * ???//from w w w . j a v a 2s. com */ @RequestMapping(value = "/build", method = RequestMethod.POST) public @ResponseBody Map<String, Object> build(BuildType buildType, Long articleCategoryId, Long productCategoryId, Date beginDate, Date endDate, Integer first, Integer count) { long startTime = System.currentTimeMillis(); if (beginDate != null) { Calendar calendar = DateUtils.toCalendar(beginDate); calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMinimum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getActualMinimum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMinimum(Calendar.SECOND)); beginDate = calendar.getTime(); } if (endDate != null) { Calendar calendar = DateUtils.toCalendar(endDate); calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMaximum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getActualMaximum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMaximum(Calendar.SECOND)); endDate = calendar.getTime(); } if (first == null || first < 0) { first = 0; } if (count == null || count <= 0) { count = 50; } int buildCount = 0; boolean isCompleted = true; if (buildType == BuildType.index) { buildCount = staticService.buildIndex(); } else if (buildType == BuildType.article) { ArticleCategory articleCategory = articleCategoryService.find(articleCategoryId); List<Article> articles = articleService.findList(articleCategory, beginDate, endDate, first, count); for (Article article : articles) { buildCount += staticService.build(article); } first += articles.size(); if (articles.size() == count) { isCompleted = false; } } else if (buildType == BuildType.product) { ProductCategory productCategory = productCategoryService.find(productCategoryId); List<Product> products = productService.findList(productCategory, beginDate, endDate, first, count); for (Product product : products) { buildCount += staticService.build(product); } first += products.size(); if (products.size() == count) { isCompleted = false; } } else if (buildType == BuildType.other) { buildCount = staticService.buildOther(); } long endTime = System.currentTimeMillis(); Map<String, Object> map = new HashMap<String, Object>(); map.put("first", first); map.put("buildCount", buildCount); map.put("buildTime", endTime - startTime); map.put("isCompleted", isCompleted); return map; }
From source file:com.lohika.alp.reporter.fe.dao.TestMethodDAOImpl.java
private DetachedCriteria getFilteredCriteria(TestMethodFilter filter) { DetachedCriteria criteria = DetachedCriteria.forClass(TestMethod.class); criteria.createAlias("testInstance", "testInstance").createAlias("testInstance.testClass", "testClass") .createAlias("testInstance.test", "test"); if (filter.getFrom() != null && filter.getTill() != null) { Calendar c = Calendar.getInstance(); c.setTime(filter.getFrom());/*from ww w.ja v a 2 s .com*/ c.set(Calendar.HOUR_OF_DAY, c.getActualMinimum(Calendar.HOUR_OF_DAY)); c.set(Calendar.MINUTE, c.getActualMinimum(Calendar.MINUTE)); c.set(Calendar.SECOND, c.getActualMinimum(Calendar.SECOND)); c.set(Calendar.MILLISECOND, c.getActualMinimum(Calendar.MILLISECOND)); Date from = c.getTime(); c.setTime(filter.getTill()); c.set(Calendar.HOUR_OF_DAY, c.getActualMaximum(Calendar.HOUR_OF_DAY)); c.set(Calendar.MINUTE, c.getActualMaximum(Calendar.MINUTE)); c.set(Calendar.SECOND, c.getActualMaximum(Calendar.SECOND)); c.set(Calendar.MILLISECOND, c.getActualMaximum(Calendar.MILLISECOND)); Date till = c.getTime(); criteria.add(Restrictions.between("startDate", from.getTime(), till.getTime())); } if (filter.getCl() != "" && filter.getCl() != null) { try { criteria.add(querytr.translate("testClass.name", filter.getCl())); } catch (QueryTranslatorException e) { // TODO Put QueryTranslatorException into log e.printStackTrace(); } } if (filter.getGr() != "" && filter.getGr() != null) { criteria.createAlias("groups", "groups"); try { criteria.add(querytr.translate("groups.name", filter.getGr())); } catch (QueryTranslatorException e) { // TODO Put QueryTranslatorException into log e.printStackTrace(); } } return criteria; }
From source file:net.groupbuy.controller.admin.SalesController.java
/** * //w w w .j av a 2s . c o m */ @RequestMapping(value = "/view", method = RequestMethod.GET) public String view(Type type, Date beginDate, Date endDate, Model model) { if (type == null) { type = Type.month; } if (beginDate == null) { beginDate = DateUtils.addMonths(new Date(), -11); } if (endDate == null) { endDate = new Date(); } Map<Date, BigDecimal> salesAmountMap = new LinkedHashMap<Date, BigDecimal>(); Map<Date, Integer> salesVolumeMap = new LinkedHashMap<Date, Integer>(); Calendar beginCalendar = DateUtils.toCalendar(beginDate); Calendar endCalendar = DateUtils.toCalendar(endDate); int beginYear = beginCalendar.get(Calendar.YEAR); int endYear = endCalendar.get(Calendar.YEAR); int beginMonth = beginCalendar.get(Calendar.MONTH); int endMonth = endCalendar.get(Calendar.MONTH); for (int year = beginYear; year <= endYear; year++) { if (salesAmountMap.size() >= MAX_SIZE) { break; } Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); if (type == Type.year) { calendar.set(Calendar.MONTH, calendar.getActualMinimum(Calendar.MONTH)); calendar.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DATE)); calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMinimum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getActualMinimum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMinimum(Calendar.SECOND)); Date begin = calendar.getTime(); calendar.set(Calendar.MONTH, calendar.getActualMaximum(Calendar.MONTH)); calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE)); calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMaximum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getActualMaximum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMaximum(Calendar.SECOND)); Date end = calendar.getTime(); BigDecimal salesAmount = orderService.getSalesAmount(begin, end); Integer salesVolume = orderService.getSalesVolume(begin, end); salesAmountMap.put(begin, salesAmount != null ? salesAmount : BigDecimal.ZERO); salesVolumeMap.put(begin, salesVolume != null ? salesVolume : 0); } else { for (int month = year == beginYear ? beginMonth : calendar.getActualMinimum(Calendar.MONTH); month <= (year == endYear ? endMonth : calendar.getActualMaximum(Calendar.MONTH)); month++) { if (salesAmountMap.size() >= MAX_SIZE) { break; } calendar.set(Calendar.MONTH, month); calendar.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DATE)); calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMinimum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getActualMinimum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMinimum(Calendar.SECOND)); Date begin = calendar.getTime(); calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE)); calendar.set(Calendar.HOUR_OF_DAY, calendar.getActualMaximum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getActualMaximum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getActualMaximum(Calendar.SECOND)); Date end = calendar.getTime(); BigDecimal salesAmount = orderService.getSalesAmount(begin, end); Integer salesVolume = orderService.getSalesVolume(begin, end); salesAmountMap.put(begin, salesAmount != null ? salesAmount : BigDecimal.ZERO); salesVolumeMap.put(begin, salesVolume != null ? salesVolume : 0); } } } model.addAttribute("types", Type.values()); model.addAttribute("type", type); model.addAttribute("beginDate", beginDate); model.addAttribute("endDate", endDate); model.addAttribute("salesAmountMap", salesAmountMap); model.addAttribute("salesVolumeMap", salesVolumeMap); return "/admin/sales/view"; }