List of usage examples for java.util Calendar HOUR_OF_DAY
int HOUR_OF_DAY
To view the source code for java.util Calendar HOUR_OF_DAY.
Click Source Link
get
and set
indicating the hour of the day. From source file:net.groupbuy.controller.admin.StaticController.java
/** * ???/*from ww w .jav 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) { 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:org.syncope.console.wicket.markup.html.form.DateTimeFieldPanel.java
public DateTimeFieldPanel(final String id, final String name, final IModel<Date> model, final boolean active, final String datePattern) { super(id, name, model, active); this.datePattern = datePattern; field = new DateTimeField("field", model); final Calendar cal = Calendar.getInstance(); field.get("hours").add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = -1107858522700306810L; @Override// w w w . ja v a2 s . c om protected void onUpdate(AjaxRequestTarget art) { if (((DateTimeField) field).getHours() > 12) { cal.set(Calendar.HOUR_OF_DAY, ((DateTimeField) field).getHours()); } else { cal.set(Calendar.HOUR, ((DateTimeField) field).getHours()); } field.setModelObject(cal.getTime()); } }); field.get("minutes").add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { cal.set(Calendar.MINUTE, ((DateTimeField) field).getMinutes()); field.setModelObject(cal.getTime()); } }); field.get("date").add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { cal.setTime(((DateTimeField) field).getDate()); if ("PM".equals("" + ((DateTimeField) field).getAmOrPm())) { cal.set(Calendar.AM_PM, Calendar.PM); } else { cal.set(Calendar.AM_PM, Calendar.AM); } field.setModelObject(cal.getTime()); } }); field.get("amOrPmChoice").add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { if ("PM".equals("" + ((DateTimeField) field).getAmOrPm())) { cal.set(Calendar.AM_PM, Calendar.PM); } else { cal.set(Calendar.AM_PM, Calendar.AM); } field.setModelObject(cal.getTime()); } }); add(field.setLabel(new Model(name)).setOutputMarkupId(true)); }
From source file:org.spc.ofp.tubs.importer.TubsTripProcessor.java
/** * combine merges a date and a time to create a single java.util.Date instance * that represents a date and time. This utility is necessary due to source data * that separates date and time fields.//from www . j a v a 2s.c o m * @param date * @param time * @return */ public static Date combine(final Date date, final String time) { if (null == date || null == time || "".equalsIgnoreCase(time)) { return date; } // FIXME Add a restriction on all Date fields in the TUBS domain such that they must be after Dec 31, 1980. final Calendar cal = new GregorianCalendar(); cal.setTime(date); try { // Get hour and minute final int hours = Integer.parseInt(time.trim().substring(0, 2)); final int minutes = Integer.parseInt(time.trim().substring(2, 4)); // Only set a valid hour and minute if (hours >= 0 && hours < 23 && minutes >= 0 && minutes < 59) { cal.set(Calendar.HOUR_OF_DAY, hours); cal.set(Calendar.MINUTE, minutes); } } catch (Exception ex) { } // NOPMD return cal.getTime(); }
From source file:Time.java
public void setHours(int hours) { calendar_.set(Calendar.HOUR_OF_DAY, hours); }
From source file:com.haulmont.timesheets.web.calendar.TimeEntryCalendarEventAdapter.java
@Override public Date getEnd() { HoursAndMinutes hoursAndMinutes = HoursAndMinutes.fromTimeEntry(timeEntry); Calendar dateCal = DateUtils.toCalendar(getStart()); dateCal.set(Calendar.HOUR_OF_DAY, hoursAndMinutes.getHours()); dateCal.set(Calendar.MINUTE, hoursAndMinutes.getMinutes()); return dateCal.getTime(); }
From source file:csns.model.academics.Assignment.java
public Assignment() { dueDate = Calendar.getInstance(); dueDate.add(Calendar.DATE, 7); dueDate.set(Calendar.HOUR_OF_DAY, 23); dueDate.set(Calendar.MINUTE, 59); dueDate.set(Calendar.SECOND, 59); dueDate.set(Calendar.MILLISECOND, 0); submissions = new ArrayList<Submission>(); fileExtensionSet = new HashSet<String>(); availableAfterDueDate = true;//from ww w. ja v a2 s . com deleted = false; }
From source file:com.netflix.simianarmy.basic.BasicCalendar.java
/** {@inheritDoc} */ @Override/* w w w. j ava 2s . c om*/ public boolean isMonkeyTime(Monkey monkey) { if (cfg != null && cfg.getStrOrElse("simianarmy.calendar.isMonkeyTime", null) != null) { return cfg.getBool("simianarmy.calendar.isMonkeyTime"); } Calendar now = now(); int dow = now.get(Calendar.DAY_OF_WEEK); if (dow == Calendar.SATURDAY || dow == Calendar.SUNDAY) { return false; } int hour = now.get(Calendar.HOUR_OF_DAY); if (hour < openHour || hour > closeHour) { return false; } if (isHoliday(now)) { return false; } return true; }
From source file:Main.java
/** * Return the preferred size of this component. * * @return the preferred size of this component. *//*from www . j a v a2 s . c om*/ public Dimension getPreferredSize() { if (null == _prefSize) { // This was originaly done every time. // and the count of instantiated objects was amazing _prefSize = new Dimension(); _prefSize.height = 20; FontMetrics fm = getFontMetrics(getFont()); Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, 23); cal.set(Calendar.MINUTE, 59); cal.set(Calendar.SECOND, 59); _prefSize.width = fm.stringWidth(_fmt.format(cal.getTime())); Border border = getBorder(); if (border != null) { Insets ins = border.getBorderInsets(this); if (ins != null) { _prefSize.width += (ins.left + ins.right); } } Insets ins = getInsets(); if (ins != null) { _prefSize.width += (ins.left + ins.right) + 20; } } return _prefSize; }
From source file:com.sirma.itt.emf.time.ISO8601DateFormat.java
/** * Format date into ISO format.//from w w w. java 2 s .com * * @param isoDate * the date to format * @return the ISO formatted string */ public static String format(Date isoDate) { if (isoDate == null) { return null; } // Note: always serialise to Gregorian Calendar Calendar calendar = new GregorianCalendar(); calendar.setTime(isoDate); StringBuilder formatted = new StringBuilder(28); padInt(formatted, calendar.get(Calendar.YEAR), 4); formatted.append('-'); padInt(formatted, calendar.get(Calendar.MONTH) + 1, 2); formatted.append('-'); padInt(formatted, calendar.get(Calendar.DAY_OF_MONTH), 2); formatted.append('T'); padInt(formatted, calendar.get(Calendar.HOUR_OF_DAY), 2); formatted.append(':'); padInt(formatted, calendar.get(Calendar.MINUTE), 2); formatted.append(':'); padInt(formatted, calendar.get(Calendar.SECOND), 2); formatted.append('.'); padInt(formatted, calendar.get(Calendar.MILLISECOND), 3); TimeZone tz = calendar.getTimeZone(); int offset = tz.getOffset(calendar.getTimeInMillis()); formatted.append(getTimeZonePadding(offset)); return formatted.toString(); }
From source file:ch.cyberduck.core.ftp.parser.StingrayFTPEntryParserTest.java
/** * http://trac.cyberduck.ch/ticket/1198//from www .jav a2 s .co m */ @Test public void testFolder() { FTPFile parsed; parsed = parser.parseFTPEntry("dr--r--r-- folder 0 Aug 1 10:18 TestCyberduck"); assertNotNull(parsed); assertEquals("TestCyberduck", parsed.getName()); assertEquals(FTPFile.DIRECTORY_TYPE, parsed.getType()); assertEquals(Calendar.AUGUST, parsed.getTimestamp().get(Calendar.MONTH)); assertEquals(1, parsed.getTimestamp().get(Calendar.DAY_OF_MONTH)); assertEquals(10, parsed.getTimestamp().get(Calendar.HOUR_OF_DAY)); assertEquals(18, parsed.getTimestamp().get(Calendar.MINUTE)); assertTrue(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.READ_PERMISSION)); assertTrue(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.READ_PERMISSION)); assertTrue(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.READ_PERMISSION)); assertFalse(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.WRITE_PERMISSION)); assertFalse(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.WRITE_PERMISSION)); assertFalse(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.WRITE_PERMISSION)); assertFalse(parsed.hasPermission(FTPFile.USER_ACCESS, FTPFile.EXECUTE_PERMISSION)); assertFalse(parsed.hasPermission(FTPFile.GROUP_ACCESS, FTPFile.EXECUTE_PERMISSION)); assertFalse(parsed.hasPermission(FTPFile.WORLD_ACCESS, FTPFile.EXECUTE_PERMISSION)); }