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.polyvi.xface.extension.XCalendarExt.java
@Override public XExtensionResult exec(String action, JSONArray args, XCallbackContext callbackCtx) throws JSONException { Calendar calendar = Calendar.getInstance(); if (COMMAND_GET_TIME.equals(action)) { // ???//from w w w. j a v a 2s. co m int hours = calendar.get(Calendar.HOUR_OF_DAY); int minutes = calendar.get(Calendar.MINUTE); if (2 == args.length()) { hours = args.getInt(0); minutes = args.getInt(1); } getTime(hours, minutes, callbackCtx); } else if (COMMAND_GET_DATE.equals(action)) { // ??? int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH) + 1; int day = calendar.get(Calendar.DAY_OF_MONTH); if (3 == args.length()) { year = args.getInt(0); month = args.getInt(1); day = args.getInt(2); } getDate(year, month, day, callbackCtx); } XExtensionResult er = new XExtensionResult(XExtensionResult.Status.NO_RESULT); return er; }
From source file:io.fourfinanceit.homework.util.RiskDefiner.java
private boolean isRiskTime() { Calendar cal = Calendar.getInstance(); int dayHour = cal.get(Calendar.HOUR_OF_DAY); if (dayHour >= riskHourFrom && dayHour < riskHourTill) { return true; } else {/* w ww . ja v a 2s . c om*/ return false; } }
From source file:Main.java
public static Date getDateTimeFrom(Date iDate, int mode, int adddate) { Calendar calendar = Calendar.getInstance(); Calendar calendarDate = Calendar.getInstance(); calendarDate.setTime(iDate);//from w ww. j a va2 s . c o m calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); switch (mode) { case Calendar.DAY_OF_MONTH: { calendar.set(Calendar.DAY_OF_MONTH, calendarDate.get(Calendar.DAY_OF_MONTH) + adddate); } break; } Date ret = calendar.getTime(); Log.v("!!!!!!!!!! calendar=", "" + ret); return ret; }
From source file:net.chrisrichardson.polyglotpersistence.restaurantmanagement.domain.TimeRange.java
public boolean isOpenAtThisTime(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date);//from w w w . j a va2 s . c o m int day = c.get(Calendar.DAY_OF_WEEK); int timeOfDay = c.get(Calendar.HOUR_OF_DAY) * 100 + c.get(Calendar.MINUTE); return day == getDayOfWeek() && openingTime <= timeOfDay && timeOfDay <= closingTime; }
From source file:com.example.geomesa.transformations.QueryTutorial.java
/** * Creates a base filter that will return a small subset of our results. This can be tweaked to * return different results if desired. Currently it should return 16 results. * * @return/* w w w .ja va 2 s. c o m*/ * * @throws CQLException * @throws IOException */ static Filter createBaseFilter() throws CQLException, IOException { // Get a FilterFactory2 to build up our query FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(); // We are going to query for events in Ukraine during the // civil unrest. // We'll start by looking at a particular day in February of 2014 Calendar calendar = Calendar.getInstance(); calendar.clear(); calendar.set(Calendar.YEAR, 2014); calendar.set(Calendar.MONTH, Calendar.FEBRUARY); calendar.set(Calendar.DAY_OF_MONTH, 2); calendar.set(Calendar.HOUR_OF_DAY, 0); Date start = calendar.getTime(); calendar.set(Calendar.HOUR_OF_DAY, 23); Date end = calendar.getTime(); Filter timeFilter = ff.between(ff.property(GdeltFeature.Attributes.SQLDATE.getName()), ff.literal(start), ff.literal(end)); // We'll bound our query spatially to Ukraine Filter spatialFilter = ff.bbox(GdeltFeature.Attributes.geom.getName(), 22.1371589, 44.386463, 40.228581, 52.379581, "EPSG:4326"); // we'll also restrict our query to only articles about the US, UK or UN Filter attributeFilter = ff.like(ff.property(GdeltFeature.Attributes.Actor1Name.getName()), "UNITED%"); // Now we can combine our filters using a boolean AND operator Filter conjunction = ff.and(Arrays.asList(timeFilter, spatialFilter, attributeFilter)); return conjunction; }
From source file:DateTimeUtil.java
/** Convert given date to string<br> * OutputFormat: yyyymmdd_hhmm/*from w w w . j av a 2 s . c om*/ * @return The Date/Time in the format: yyyymmdd_hhmm */ public static String convertToDateStamp(Calendar cal) { String year = String.valueOf(cal.get(Calendar.YEAR)); String month = String.valueOf(cal.get(Calendar.MONTH) + 1); if (month.length() == 1) { month = "0" + month; } String day = String.valueOf(cal.get(Calendar.DAY_OF_MONTH)); if (day.length() == 1) { day = "0" + day; } String hour = String.valueOf(cal.get(Calendar.HOUR_OF_DAY)); if (hour.length() == 1) { hour = "0" + hour; } String minute = String.valueOf(cal.get(Calendar.MINUTE)); if (minute.length() == 1) { minute = "0" + minute; } String second = String.valueOf(cal.get(Calendar.SECOND)); if (second.length() == 1) { second = "0" + second; } String dateStamp = year + month + day + "_" + hour + minute + second; return dateStamp; }
From source file:es.tekniker.framework.ktek.util.Utils.java
public static long getTimeinMillis4FullDateTimeGMT(int year, int month, int day, int hours, int minutes, int seconds) { Calendar c = getCalendarGMT(); c.set(Calendar.YEAR, year);// w w w . j av a 2 s . c o m c.set(Calendar.MONTH, month); c.set(Calendar.DAY_OF_MONTH, day); c.set(Calendar.HOUR_OF_DAY, hours); c.set(Calendar.MINUTE, minutes); c.set(Calendar.SECOND, seconds); System.out.println("New Time: " + c.getTime()); long timeinmillis = c.getTimeInMillis(); System.out.println(" system time in millis " + timeinmillis); return timeinmillis; }
From source file:com.lfv.yada.net.server.ServerLogger.java
public ServerLogger(int groupId, String logpath) { // Create a logger for this class if (logpath == null) { logpath = "data/logs/"; }//from www. j a va 2 s . c o m mylogpath = logpath; log = LogFactory.getLog(getClass()); log.info("ServerLogger: logpath=" + logpath); // Create a calendar startTime = System.currentTimeMillis(); calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); calendar.setTimeInMillis(startTime); String filename = "Grp" + groupId + "-" + calendar.get(Calendar.YEAR) + s2(calendar.get(Calendar.MONTH) + 1) + s2(calendar.get(Calendar.DAY_OF_MONTH)) + "-" + s2(calendar.get(Calendar.HOUR_OF_DAY)) + s2(calendar.get(Calendar.MINUTE)) + s2(calendar.get(Calendar.SECOND)) + ".log"; try { printer = new PrintStream(new FileOutputStream(logpath + "/" + filename), true); log.info("Creating log " + logpath + "/" + filename); } catch (FileNotFoundException ex) { log.warn("Log file " + filename + " could not be created, logger has been disabled!", ex); printer = null; } }
From source file:com.fluke.util.Util.java
public static String getTime(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);/* w w w . j a v a 2 s.c om*/ return calendar.get(Calendar.HOUR_OF_DAY) + ":" + calendar.get(Calendar.MINUTE); }
From source file:org.openmrs.module.openconceptlab.scheduler.UpdateScheduler.java
@SuppressWarnings("unchecked") public synchronized void schedule(Subscription subscription) { updateService.saveSubscription(subscription); if (scheduledUpdate != null) { scheduledUpdate.cancel(false);/*from w w w .j av a2s . c om*/ } if (subscription.getDays() != 0 || subscription.getHours() != 0 || subscription.getMinutes() != 0) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, subscription.getHours()); calendar.set(Calendar.MINUTE, subscription.getMinutes()); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); scheduledUpdate = scheduler.scheduleAtFixedRate(updater, calendar.getTime(), subscription.getDays() * DAY_PERIOD); } }