List of usage examples for java.util Calendar MINUTE
int MINUTE
To view the source code for java.util Calendar MINUTE.
Click Source Link
get
and set
indicating the minute within the hour. 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 ww w.j a v a2s .co m return facturas; }
From source file:DateParser.java
private static Calendar getCalendar(String isodate) { // YYYY-MM-DDThh:mm:ss.sTZD StringTokenizer st = new StringTokenizer(isodate, "-T:.+Z", true); Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); calendar.clear();//from www .j a v a 2 s . c o m try { // Year if (st.hasMoreTokens()) { int year = Integer.parseInt(st.nextToken()); calendar.set(Calendar.YEAR, year); } else { return calendar; } // Month if (check(st, "-") && (st.hasMoreTokens())) { int month = Integer.parseInt(st.nextToken()) - 1; calendar.set(Calendar.MONTH, month); } else { return calendar; } // Day if (check(st, "-") && (st.hasMoreTokens())) { int day = Integer.parseInt(st.nextToken()); calendar.set(Calendar.DAY_OF_MONTH, day); } else { return calendar; } // Hour if (check(st, "T") && (st.hasMoreTokens())) { int hour = Integer.parseInt(st.nextToken()); calendar.set(Calendar.HOUR_OF_DAY, hour); } else { calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar; } // Minutes if (check(st, ":") && (st.hasMoreTokens())) { int minutes = Integer.parseInt(st.nextToken()); calendar.set(Calendar.MINUTE, minutes); } else { calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); return calendar; } // // Not mandatory now // // Secondes if (!st.hasMoreTokens()) { return calendar; } String tok = st.nextToken(); if (tok.equals(":")) { // secondes if (st.hasMoreTokens()) { int secondes = Integer.parseInt(st.nextToken()); calendar.set(Calendar.SECOND, secondes); if (!st.hasMoreTokens()) { return calendar; } // frac sec tok = st.nextToken(); if (tok.equals(".")) { // bug fixed, thx to Martin Bottcher String nt = st.nextToken(); while (nt.length() < 3) { nt += "0"; } nt = nt.substring(0, 3); // Cut trailing chars.. int millisec = Integer.parseInt(nt); // int millisec = Integer.parseInt(st.nextToken()) * 10; calendar.set(Calendar.MILLISECOND, millisec); if (!st.hasMoreTokens()) { return calendar; } tok = st.nextToken(); } else { calendar.set(Calendar.MILLISECOND, 0); } } else { throw new RuntimeException("No secondes specified"); } } else { calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); } // Timezone if (!tok.equals("Z")) { // UTC if (!(tok.equals("+") || tok.equals("-"))) { throw new RuntimeException("only Z, + or - allowed"); } boolean plus = tok.equals("+"); if (!st.hasMoreTokens()) { throw new RuntimeException("Missing hour field"); } int tzhour = Integer.parseInt(st.nextToken()); int tzmin = 0; if (check(st, ":") && (st.hasMoreTokens())) { tzmin = Integer.parseInt(st.nextToken()); } else { throw new RuntimeException("Missing minute field"); } if (plus) { calendar.add(Calendar.HOUR, -tzhour); calendar.add(Calendar.MINUTE, -tzmin); } else { calendar.add(Calendar.HOUR, tzhour); calendar.add(Calendar.MINUTE, tzmin); } } } catch (NumberFormatException ex) { throw new RuntimeException("[" + ex.getMessage() + "] is not an integer"); } return calendar; }
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);/* w w w.ja v a 2s . c om*/ 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.autentia.common.util.DateFormater.java
public static Date normalizeInitDate(Date date) { GregorianCalendar gCalendar = new GregorianCalendar(); gCalendar.setTime(date);/*from w w w .jav a2 s .c om*/ 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 w w w .j a v a 2s .c om }
From source file:siia.business.FlightEventTransformer.java
public FlightDelayEvent convertToDelayEvent(String flightNumberAndDelay) { String[] splits = flightNumberAndDelay.split("[+]"); Flight flight = this.flightScheduler.nextFlightForNumber(splits[0]); int hours = Integer.parseInt(splits[1].substring(0, 2)); int minutes = Integer.parseInt(splits[1].substring(2)); Calendar cal = Calendar.getInstance(); cal.setTime(flight.getScheduledDeparture()); cal.add(Calendar.HOUR, hours); cal.add(Calendar.MINUTE, minutes); return new FlightDelayEvent(flight, cal.getTime()); }
From source file:at.christophwurst.orm.service.BurnDownServiceImpl.java
private Date stripDate(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from w ww. ja v a 2s . c o m*/ 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(); }
From source file:com.timesheet.utils.Utils.java
public Date dateModification(Date date, String time) { Date modifiedDate = null;//from w w w . j av a 2 s . c o m if (date != null && StringUtils.isNotBlank(time)) { String hhStr = time.split(":")[0]; String mmStr = time.split(":")[1]; Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(Calendar.HOUR, calendar.get(Calendar.HOUR) + Integer.parseInt(hhStr)); calendar.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE) + Integer.parseInt(mmStr)); modifiedDate = calendar.getTime(); } return modifiedDate; }
From source file:com.google.orkut.client.api.Util.java
static String getFormattedTimestamp(long timeMillis) { Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(Constants.DateFormatter.UTC)); cal.setTimeInMillis(timeMillis);/* w ww.ja v a 2s. c o m*/ StringBuilder date = new StringBuilder(); date.append(cal.get(Calendar.YEAR)); date.append(Constants.DateFormatter.DATE_SEPARATOR); date.append(padSingleDigitNum(cal.get(Calendar.MONTH) + 1)); date.append(Constants.DateFormatter.DATE_SEPARATOR); date.append(padSingleDigitNum(cal.get(Calendar.DATE))); date.append(Constants.DateFormatter.DATE_DELIM); date.append(padSingleDigitNum(cal.get(Calendar.HOUR))); date.append(Constants.DateFormatter.TIME_SEPARATOR); date.append(padSingleDigitNum(cal.get(Calendar.MINUTE))); date.append(Constants.DateFormatter.TIME_SEPARATOR); date.append(padSingleDigitNum(cal.get(Calendar.SECOND))); date.append(Constants.DateFormatter.TIME_DELIM); return date.toString(); }