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.linuxbox.enkive.teststats.StatsDayGrainTest.java
@BeforeClass public static void setUp() throws ParseException, GathererException { coll = TestHelper.GetTestCollection(); client = TestHelper.BuildClient();/*from w w w.ja v a 2s . c o m*/ grain = new DayConsolidator(client); List<Map<String, Object>> stats = (new HourConsolidator(client)).consolidateData(); Map<String, Object> timeMap = new HashMap<String, Object>(); Calendar cal = Calendar.getInstance(); cal.set(Calendar.MILLISECOND, 0); cal.set(Calendar.SECOND, 1); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.HOUR, 0); for (int i = 0; i < 10; i++) { if (i == 5) { cal.add(Calendar.DATE, -1); } timeMap.put(CONSOLIDATION_MAX, cal.getTime()); timeMap.put(CONSOLIDATION_MIN, cal.getTime()); for (Map<String, Object> data : stats) { data.put(STAT_TIMESTAMP, timeMap); } client.storeData(stats); } dataCount = coll.count(); }
From source file:com.digitalpebble.stormcrawler.persistence.DefaultSchedulerTest.java
@Test public void testScheduler() throws MalformedURLException { Map<String, Object> stormConf = new HashMap<>(); stormConf.put("fetchInterval.testKey=someValue", 3600); DefaultScheduler scheduler = new DefaultScheduler(); scheduler.init(stormConf);/* w ww . ja va 2 s . c o m*/ Metadata metadata = new Metadata(); metadata.addValue("testKey", "someValue"); Date nextFetch = scheduler.schedule(Status.FETCHED, metadata); Calendar cal = Calendar.getInstance(); cal.add(Calendar.MINUTE, 3600); Assert.assertEquals(DateUtils.round(cal.getTime(), Calendar.SECOND), DateUtils.round(nextFetch, Calendar.SECOND)); }
From source file:TimeUtil.java
public static long dateFormat(short weekMins) { long dateMillis = System.currentTimeMillis(); synchronized (statFmtCal) { statFmtCal.setTime(new Date(dateMillis)); // get the day of the week int nowDay = statFmtCal.get(Calendar.DAY_OF_WEEK) - 1; // get day of the week of stat time int statDay = weekMins / 1440; if (nowDay > statDay) { dateMillis -= (nowDay - statDay) * 1440 * 60 * 1000; } else if (nowDay < statDay) { dateMillis += (statDay - nowDay) * 1440 * 60 * 1000; }/*from www. j a va2 s. co m*/ // now get the hour of the day int nowHour = statFmtCal.get(Calendar.HOUR_OF_DAY); int statHour = (weekMins % 1440) / 60; if (nowHour > statHour) { dateMillis -= (nowHour - statHour) * 60 * 60 * 1000; } else if (nowHour < statHour) { dateMillis += (statHour - nowHour) * 60 * 60 * 1000; } // finally minutes int nowMins = statFmtCal.get(Calendar.MINUTE); int statMins = (weekMins % 1440) % 60; if (nowMins > statMins) { dateMillis -= (nowMins - statMins) * 60 * 1000; } else if (nowMins < statMins) { dateMillis += (statMins - nowMins) * 60 * 1000; } } return dateMillis; }
From source file:com.intuit.tank.report.JobReportOptions.java
public Date getStartTime() { Date ret = null;/*from w w w.j a va 2s .com*/ if (startDate != null) { Calendar cal = Calendar.getInstance(); cal.setTime(startDate); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); if (StringUtils.isNotBlank(startTimeString)) { try { Calendar parsed = Calendar.getInstance(); parsed.setTime(tf.parse(startTimeString)); cal.set(Calendar.HOUR_OF_DAY, parsed.get(Calendar.HOUR_OF_DAY)); cal.set(Calendar.MINUTE, parsed.get(Calendar.MINUTE)); } catch (ParseException e) { LOG.warn("Could not parse time string " + startTimeString); } } ret = cal.getTime(); } return ret; }
From source file:Main.java
/** * Parse a date from ISO-8601 formatted string. It expects a format yyyy-MM-ddThh:mm:ss[.sss][Z|[+-]hh:mm] * * @param date ISO string to parse in the appropriate format. * @return the parsed date/*from w w w . j a v a 2s . c om*/ * @throws IllegalArgumentException if the date is not in the appropriate format */ public static Date parse(String date) { try { int offset = 0; // extract year int year = parseInt(date, offset, offset += 4); checkOffset(date, offset, '-'); // extract month int month = parseInt(date, offset += 1, offset += 2); checkOffset(date, offset, '-'); // extract day int day = parseInt(date, offset += 1, offset += 2); checkOffset(date, offset, 'T'); // extract hours, minutes, seconds and milliseconds int hour = parseInt(date, offset += 1, offset += 2); checkOffset(date, offset, ':'); int minutes = parseInt(date, offset += 1, offset += 2); checkOffset(date, offset, ':'); int seconds = parseInt(date, offset += 1, offset += 2); // milliseconds can be optional in the format int milliseconds = 0; // always use 0 otherwise returned date will include millis of current time if (date.charAt(offset) == '.') { checkOffset(date, offset, '.'); milliseconds = parseInt(date, offset += 1, offset += 3); } // extract timezone String timezoneId; char timezoneIndicator = date.charAt(offset); if (timezoneIndicator == '+' || timezoneIndicator == '-') { timezoneId = GMT_ID + date.substring(offset); } else if (timezoneIndicator == 'Z') { timezoneId = GMT_ID; } else { throw new IndexOutOfBoundsException("Invalid time zone indicator " + timezoneIndicator); } TimeZone timezone = TimeZone.getTimeZone(timezoneId); if (!timezone.getID().equals(timezoneId)) { throw new IndexOutOfBoundsException(); } Calendar calendar = new GregorianCalendar(timezone); calendar.setLenient(false); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month - 1); calendar.set(Calendar.DAY_OF_MONTH, day); calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minutes); calendar.set(Calendar.SECOND, seconds); calendar.set(Calendar.MILLISECOND, milliseconds); return calendar.getTime(); } catch (IndexOutOfBoundsException e) { throw new IllegalArgumentException("Failed to parse date " + date, e); } catch (NumberFormatException e) { throw new IllegalArgumentException("Failed to parse date " + date, e); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Failed to parse date " + date, e); } }
From source file:com.liusoft.dlog4j.util.DateUtils.java
/** * /* w w w.j av a 2s. c om*/ * @param cal */ public static void resetTime(Calendar cal) { cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); }
From source file:com.ar.dev.tierra.api.dao.impl.FacturaDAOImpl.java
@Override public List<Factura> getDiary() { Criteria criteria = getSession().createCriteria(Factura.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.asc("idFactura")); criteria.add(Restrictions.not(Restrictions.in("estado", new String[] { "RESERVADO" }))); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); criteria.addOrder(Order.desc("idFactura")); List<Factura> list = criteria.list(); return list;/*from w w w . j av a2 s . c o m*/ }
From source file:net.chrisrichardson.foodToGo.restaurantNotificationService.tsImpl.dao.OrderDAOIBatisImpl.java
Timestamp calculateCutOffTime() { Calendar c = Calendar.getInstance(); c.add(Calendar.MINUTE, -timeWindowInMinutes); long cutOffTime = c.getTimeInMillis(); return new Timestamp(cutOffTime); }
From source file:com.linuxbox.enkive.teststats.StatsWeekGrainTest.java
@BeforeClass public static void setUp() throws ParseException, GathererException { coll = TestHelper.GetTestCollection(); client = TestHelper.BuildClient();/* ww w.ja va 2 s. c o m*/ grain = new WeekConsolidator(client); List<Map<String, Object>> stats = (new DayConsolidator(client)).consolidateData(); Map<String, Object> timeMap = createMap(); Calendar cal = Calendar.getInstance(); cal.set(Calendar.MILLISECOND, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.HOUR, 0); for (int i = 0; i < 10; i++) { if (i == 5) { cal.add(Calendar.WEEK_OF_MONTH, -1); } timeMap.put(CONSOLIDATION_MAX, cal.getTime()); timeMap.put(CONSOLIDATION_MIN, cal.getTime()); for (Map<String, Object> data : stats) { data.put(STAT_TIMESTAMP, timeMap); } client.storeData(stats); } dataCount = coll.count(); }
From source file:com.ov.project.dev.crawler.ClientOVSocket.java
/** * /*from ww w . j a v a 2s . c o m*/ * Thread d' appel aux prdiction */ public void open() { Thread lThread = new Thread(new Runnable() { public void run() { while (mIsRunning == true) { Map<VelibKey, Integer> lMap = new HashMap<VelibKey, Integer>(); try { SparkManager.getInstance().init(BundelUtils.get("hadoop.home")); VelibProvider lProvider = new VelibProvider(BundelUtils.get("license.path")); lMap = lProvider.predict(BundelUtils.get("data.frame.path"), BundelUtils.get("static.path"), BundelUtils.get("model.path"), BundelUtils.get("hadoop.home"), Calendar.MINUTE, lValue); // Map => <VelibStation, Prediction> // VelibClient client = new VelibClient(Constants.sHost, // Constants.sPort, lMap); } catch (Exception e) { e.printStackTrace(); } } } }); lThread.start(); }