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:Main.java
/** * Adds a number of hours to a date returning a new object. * The original date object is unchanged. * * @param date the date, not null/*from w w w . j av a2 s . c om*/ * @param amount the amount to add, may be negative * @return the new date object with the amount added * @throws IllegalArgumentException if the date is null */ public static Date addHours(Date date, int amount) { return add(date, Calendar.HOUR_OF_DAY, amount); }
From source file:com.ykun.commons.utils.commons.DateUtils.java
/** * ?/* w w w .j a v a 2 s . co m*/ * * @param date * @param hourAmount * @return Date */ public static Date addHour(Date date, int hourAmount) { return addInteger(date, Calendar.HOUR_OF_DAY, hourAmount); }
From source file:com.ar.dev.tierra.api.service.FacturaService.java
public Page getFacturasDay(Integer page, Integer size, int idSucursal) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); Date fromDate = calendar.getTime(); calendar.set(Calendar.HOUR_OF_DAY, 23); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.SECOND, 59); Date toDate = calendar.getTime(); Page facturas = facturaRepository.findFacturasByDate(fromDate, toDate, new PageRequest(page, size), idSucursal);/*from w w w .j a v a 2 s.c o m*/ return facturas; }
From source file:Main.java
/** * Sets the hours field to a date returning a new object. Hours range * from 0-23./*from www . java 2 s .c o m*/ * The original date object is unchanged. * * @param date the date, not null * @param amount the amount to set * @return a new Date object set with the specified value * @throws IllegalArgumentException if the date is null * @since 2.4 */ public static Date setHours(Date date, int amount) { return set(date, Calendar.HOUR_OF_DAY, amount); }
From source file:com.collabnet.ccf.core.utils.DateUtil.java
public static Date convertDateToTimeZone(Date date, String toTimeZone) { Calendar toCal = new GregorianCalendar(TimeZone.getTimeZone(toTimeZone)); Calendar fromCal = new GregorianCalendar(); fromCal.setTime(date);/*from ww w. jav a 2 s . c o m*/ toCal.set(fromCal.get(Calendar.YEAR), fromCal.get(Calendar.MONTH), fromCal.get(Calendar.DAY_OF_MONTH), fromCal.get(Calendar.HOUR_OF_DAY), fromCal.get(Calendar.MINUTE), fromCal.get(Calendar.SECOND)); toCal.set(Calendar.MILLISECOND, fromCal.get(Calendar.MILLISECOND)); return toCal.getTime(); }
From source file:com.jhkt.playgroundArena.examples.generic.interceptors.OpenTimeInterceptor.java
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { Calendar cal = Calendar.getInstance(); int hour = cal.get(Calendar.HOUR_OF_DAY); if (openingTime <= hour && hour < closingTime) { return true; } else {// w w w . ja v a 2s. co m response.sendRedirect("http://localhost/closed.html"); return false; } }
From source file:com.autentia.common.util.DateFormater.java
public static Date normalizeInitDate(Date date) { GregorianCalendar gCalendar = new GregorianCalendar(); gCalendar.setTime(date);//from ww w .j a v a 2 s . c o m gCalendar.set(Calendar.HOUR_OF_DAY, 0); gCalendar.set(Calendar.MINUTE, 0); gCalendar.set(Calendar.SECOND, 0); gCalendar.set(Calendar.MILLISECOND, 0); return gCalendar.getTime(); }
From source file:net.kamhon.ieagle.util.DateUtil.java
public static Date addTime(Date date, Date time) { Calendar timeCal = setTime(time); int hour = timeCal.get(Calendar.HOUR_OF_DAY); int mins = timeCal.get(Calendar.MINUTE); int secs = timeCal.get(Calendar.SECOND); Calendar cal = setTime(date); cal.set(Calendar.HOUR_OF_DAY, hour); cal.set(Calendar.MINUTE, mins); cal.set(Calendar.SECOND, secs); return cal.getTime(); }
From source file:com.ar.dev.tierra.api.dao.impl.TransferenciaDAOImpl.java
@Override public List<Transferencia> getDaily() { Criteria criteria = getSession().createCriteria(Transferencia.class); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); Date fromDate = calendar.getTime(); calendar.set(Calendar.HOUR_OF_DAY, 23); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.SECOND, 59); Date toDate = calendar.getTime(); criteria.add(Restrictions.between("fechaCreacion", fromDate, toDate)); criteria.addOrder(Order.desc("idTransferencia")); List<Transferencia> list = criteria.list(); return list;/*from ww w . j a va 2 s .c o m*/ }
From source file:at.christophwurst.orm.service.BurnDownServiceImpl.java
private Date stripDate(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);//from w w w . j a va 2 s .com cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); }