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:com.aimdek.ccm.dao.impl.test.CreditCardDaoImplTest.java
/** * initialize.//from ww w . ja v a 2s. co m */ @Before public void initialize() { List<CreditCard> creditcardList = new ArrayList<CreditCard>(); CreditCard creditCard = new CreditCard(); creditCard.setAvailableCreditLimit(15000); creditCard.setCardNumber("1234-1234-1234-0008"); creditCard.setCreditLimit(20000); creditCard.setCvv(420); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_MONTH, -1); calendar.set(Calendar.HOUR_OF_DAY, 23); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.SECOND, 59); creditCard.setLastStatementDate(calendar.getTime()); creditCard.setStatementDate(new Date()); creditCard.setNameOnCard("Test1 Test1"); creditCard.setCardHolderId(1); creditCard.setValidFromDate(new Date()); creditCard.setValidToDate(new Date()); creditCardRepository.saveCreditCard(creditCard); creditCardId = creditCard.getId(); CreditCard creditCard1 = new CreditCard(); creditCard1.setAvailableCreditLimit(15000); creditCard1.setCardNumber("2345-1234-2345-0009"); creditCard1.setCreditLimit(20000); creditCard1.setCvv(420); creditCard1.setLastStatementDate(calendar.getTime()); creditCard1.setStatementDate(new Date()); creditCard1.setNameOnCard("Test2 Test2"); creditCard1.setCardHolderId(2); creditCard1.setValidFromDate(new Date()); creditCard1.setValidToDate(new Date()); creditcardList.add(creditCard1); CreditCard creditCard2 = new CreditCard(); creditCard2.setAvailableCreditLimit(15000); creditCard2.setCardNumber("1234-1234-1234-0010"); creditCard2.setCreditLimit(20000); creditCard2.setCvv(420); creditCard2.setLastStatementDate(calendar.getTime()); creditCard2.setStatementDate(new Date()); creditCard2.setNameOnCard("Test3 Test3"); creditCard2.setCardHolderId(3); creditCard2.setValidFromDate(new Date()); creditCard2.setValidToDate(new Date()); creditcardList.add(creditCard2); CreditCard creditCard3 = new CreditCard(); creditCard3.setAvailableCreditLimit(15000); creditCard3.setCardNumber("2345-1234-2345-0011"); creditCard3.setCreditLimit(20000); creditCard3.setCvv(420); creditCard3.setLastStatementDate(calendar.getTime()); creditCard3.setStatementDate(new Date()); creditCard3.setNameOnCard("Test4 Test4"); creditCard3.setCardHolderId(4); creditCard3.setValidFromDate(new Date()); creditCard3.setValidToDate(new Date()); creditcardList.add(creditCard3); CreditCard creditCard5 = new CreditCard(); creditCard5.setAvailableCreditLimit(15000); creditCard5.setCardNumber("1234-1234-1234-0012"); creditCard5.setCreditLimit(20000); creditCard5.setCvv(420); creditCard5.setLastStatementDate(calendar.getTime()); creditCard5.setStatementDate(new Date()); creditCard5.setNameOnCard("Test3 Test3"); creditCard5.setCardHolderId(4); creditCard5.setValidFromDate(new Date()); creditCard5.setValidToDate(new Date()); creditcardList.add(creditCard5); creditCardRepository.save(creditcardList); }
From source file:org.openmrs.module.pharmacyapi.api.prescription.util.NewPrescriptionItemGenerator.java
private Date getExpirationDateMinus2Days(final PrescriptionItem item) { final Calendar calendar = Calendar.getInstance(); calendar.setTime(item.getDrugOrder().getEncounter().getDateCreated()); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.DAY_OF_MONTH, 10); while ((calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) || (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)) { calendar.add(Calendar.DAY_OF_MONTH, 1); }//from w w w.ja v a 2 s.co m return calendar.getTime(); }
From source file:erpsystem.chart.Charts.java
private static Calendar copyCalendar(Calendar calendar) { Calendar result = Calendar.getInstance(); result.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND)); return result; }
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());//from ww w. j a v a 2 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:com.adobe.acs.commons.http.headers.impl.AbstractExpiresHeaderFilter.java
@Override protected String getHeaderValue() { Calendar next = Calendar.getInstance(); next.set(Calendar.HOUR_OF_DAY, expiresTime.get(Calendar.HOUR_OF_DAY)); next.set(Calendar.MINUTE, expiresTime.get(Calendar.MINUTE)); next.set(Calendar.SECOND, 0); adjustExpires(next);// ww w . j a v a2 s . c om SimpleDateFormat dateFormat = new SimpleDateFormat(EXPIRES_FORMAT); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); return dateFormat.format(next.getTime()); }
From source file:fr.syncarnet.tasks.Task.java
/** * Builds a task object giving it a unique UUID and storing the current time as entry date. * @param description//from ww w. ja v a 2 s . c om * The description of the task * @param due * Set it to <b>null</b> if not used * @param project * Set it to <b>null</b> if not used * @param priority * Set it to <b>MEDIUM</b> if not used */ public Task(String description, Calendar due, String project, Priority priority) { this.entry = new Date().getTime(); this.uuid = UUID.randomUUID(); this.description = description; if (due != null) { due.set(Calendar.HOUR_OF_DAY, 0); due.set(Calendar.MINUTE, 0); due.set(Calendar.SECOND, 0); due.set(Calendar.MILLISECOND, 0); } this.due = due; if (project != null && !project.equals("")) { this.project = project; } this.priority = priority; }
From source file:com.silverpeas.calendar.DateTime.java
/** * Creates a new date time from the specified parts of the time specification year month day hour * minute second millisecond. The hour, minute, second and millisecond parts are optional; if not * passed, they are set at 0. For example, the following patterns are valid: * <ul>/* w ww. j a v a2 s . com*/ * <li>at(2011, 5, 23, 10, 57, 23, 12) meaning in ISO 86601 2011-05-23T10:57:23.012</li> * <li>at(2011, 5, 23, 10, 57, 23) meaning in ISO 86601 2011-05-23T10:57:23.00</li> * <li>at(2011, 5, 23, 10, 57) meaning in ISO 86601 2011-05-23T10:57:00.00</li> * <li>at(2011, 5, 23, 10) meaning in ISO 86601 2011-05-23T10:00:00.00</li> * <li>at(2011, 5, 23) meaning in ISO 86601 2011-05-23T00:00:00.00</li> * </ul> * @param timeParts the different parts of the date time to set in the following order: year, * month, day, hour, minute, second, millisecond. The year, month, and day are mandatory whereas * other time parts are optional. If one optional part isn't passed, then it is set to 0. * @return a date time matching the specified date and time specification. */ public static DateTime dateTimeAt(int... timeParts) { if (timeParts.length < 3) { throw new IllegalArgumentException("The year, month and day must be set"); } Calendar calendar = Calendar.getInstance(); calendar.set(timeParts[0], timeParts[1], timeParts[2], 0, 0, 0); calendar.set(Calendar.MILLISECOND, 0); if (timeParts.length >= 4) { calendar.set(Calendar.HOUR_OF_DAY, timeParts[3]); if (timeParts.length >= 5) { calendar.set(Calendar.MINUTE, timeParts[4]); if (timeParts.length >= 6) { calendar.set(Calendar.SECOND, timeParts[5]); if (timeParts.length >= 7) { calendar.set(Calendar.MILLISECOND, timeParts[6]); } } } } return new DateTime(calendar.getTime()); }
From source file:churashima.action.manage.ExpensesAction.java
@Execute(validator = false) public String index() { Date date = new Date(); if (StringUtils.isEmpty(expensesForm.strDate)) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); expensesForm.strDate = sdf.format(date); }/* w ww.j a v a2s. c o m*/ Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); ExpensesDao expensesDao = SingletonS2Container.getComponent(ExpensesDao.class); List<Expenses> expensesList = expensesDao.selectForSearch(null, null, null, null, null, null, null, null, new Timestamp(cal.getTimeInMillis())); expensesForm.expensesList = expensesList; // expensesForm.subjectId = null; expensesForm.place = null; expensesForm.name = null; expensesForm.price = BigDecimal.valueOf(0); expensesForm.comment = null; expensesForm.isExcludeTax = null; SubjectDao subjectDao = SingletonS2Container.getComponent(SubjectDao.class); expensesForm.subjectList = subjectDao.selectForSearch(null, Const.STATUS_STARTING); return "expenses.jsp"; }
From source file:net.chrisrichardson.foodToGo.domain.hibernate.HibernateRestaurantRepositoryImpl.java
Object[] makeParameterValues(Address deliveryAddress, Date deliveryTime) { Calendar c = Calendar.getInstance(); c.setTime(deliveryTime);// ww w. j a va2 s. c om int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); int timeOfDay = c.get(Calendar.HOUR_OF_DAY) * 100 + c.get(Calendar.MINUTE); String zipCode = deliveryAddress.getZip(); Object[] values = new Object[] { zipCode, new Integer(dayOfWeek), new Integer(timeOfDay) }; return values; }
From source file:com.qpark.eip.core.spring.statistics.dao.StatisticsLoggingDao.java
/** * Get a {@link Date}, where hours, minutes, seconds and milliseconds are * set to 0.//from ww w . j a va 2 s .c o m * * @return the {@link Date} . */ private static Date getDayStart(final Date d) { final Calendar gc = new GregorianCalendar(LOGGING_TIMEZONE); gc.setTime(d); gc.set(Calendar.HOUR_OF_DAY, 0); gc.set(Calendar.MINUTE, 0); gc.set(Calendar.SECOND, 0); gc.set(Calendar.MILLISECOND, 0); return gc.getTime(); }