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:net.seratch.taskun.util.CalendarUtil.java
public static Calendar getCalendar(String yyyy, String mm, String dd, String hh, String mi, String ss) { Calendar cal = getCalendar(yyyy, mm, dd); cal.set(Calendar.HOUR_OF_DAY, Integer.valueOf(hh)); cal.set(Calendar.MINUTE, Integer.valueOf(mi)); cal.set(Calendar.SECOND, Integer.valueOf(ss)); return cal;//www . j av a 2s . co m }
From source file:XSDDateTime.java
public static String getDateTime(Calendar cal) { if (!cal.getTimeZone().equals(TimeZone.getTimeZone("GMT+00:00"))) { throw new InvalidParameterException(); }//from w w w . j av a 2s . c o m int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH); month++; String monthString = pad(month); int day = cal.get(Calendar.DAY_OF_MONTH); String dayString = pad(day); int hour = cal.get(Calendar.HOUR_OF_DAY); String hourString = pad(hour); int minutes = cal.get(Calendar.MINUTE); String minutesString = pad(minutes); int seconds = cal.get(Calendar.SECOND); String secondsString = pad(seconds); return year + "-" + monthString + "-" + dayString + "T" + hourString + ":" + minutesString + ":" + secondsString + "Z"; }
From source file:io.fourfinanceit.homework.util.RiskDefiner.java
private boolean isLowedCountloans(LoanApplication loanApplication) { Calendar cal = Calendar.getInstance(); cal.add(Calendar.HOUR_OF_DAY, -24); Date date = cal.getTime();/* w w w .ja v a 2s . c o m*/ String ipAddress = loanApplication.getIpAddress(); List<LoanApplication> loanApplications = loanApplicationRepository .findByIpAddressAndStatusAndInsertDateGreaterThan(ipAddress, LoanApplicationStatusEnum.ACTIVE.getStatus(), cal.getTime()); if (loanApplications.size() >= maxApplicationsPerDay) { return false; } else { return true; } }
From source file:org.atomspace.ultrahouse3000.translator.Message2DocumentTranslator.java
void addCalenderInformation(Message message) { Calendar cal = Calendar.getInstance(); message.setHeader("timestamp", cal.getTimeInMillis()); message.setHeader("calendarYear", cal.get(Calendar.YEAR)); message.setHeader("calendarDayOfMonth", cal.get(Calendar.DAY_OF_MONTH)); message.setHeader("calendarMonth", cal.get(Calendar.MONTH)); message.setHeader("calendarDayOfYear", cal.get(Calendar.DAY_OF_YEAR)); message.setHeader("calendarHourOfDay", cal.get(Calendar.HOUR_OF_DAY)); message.setHeader("calendarMinute", cal.get(Calendar.MINUTE)); message.setHeader("calendarSecond", cal.get(Calendar.SECOND)); message.setHeader("calendarWeekOfYear", cal.get(Calendar.WEEK_OF_YEAR)); message.setHeader("calendarDayOfWeek", cal.get(Calendar.DAY_OF_WEEK)); }
From source file:it.generatore.DateRandomGaussianGeneratorTest.java
private static String getHourKey(Calendar cal) { return StringUtils.leftPad(String.valueOf(cal.get(Calendar.HOUR_OF_DAY)), 2, '0') + ":" + StringUtils.leftPad(String.valueOf(cal.get(Calendar.MINUTE)), 2, '0'); }
From source file:com.adsapient.shared.service.TimeService.java
public static final boolean isInBlockTime(String beginTime, String endTime) throws IncorrectDateException { int beginHour; int endHour;/*from www. j a v a2 s .c o m*/ int beginMinute; int endMinute; Calendar calendar = Calendar.getInstance(); int currentHour = calendar.get(Calendar.HOUR_OF_DAY); int currentMinute = calendar.get(Calendar.MINUTE); if (StringUtils.isEmpty(beginTime) | StringUtils.isEmpty(endTime)) { throw new IncorrectDateException("Date string is empty."); } StringTokenizer begin = new StringTokenizer(beginTime, ":"); StringTokenizer end = new StringTokenizer(endTime, ":"); if (!begin.hasMoreTokens()) { throw new IncorrectDateException("Begin time was not specified."); } if (!end.hasMoreTokens()) { throw new IncorrectDateException("End time was not specified."); } String tempBH = begin.nextToken(); String tempEH = end.nextToken(); try { beginHour = Integer.parseInt(tempBH); endHour = Integer.parseInt(tempEH); } catch (NumberFormatException e) { throw new IncorrectDateException("Year parameter should be numeric."); } String tempBM = begin.nextToken(); String tempEM = end.nextToken(); try { beginMinute = Integer.parseInt(tempBM); endMinute = Integer.parseInt(tempEM); } catch (NumberFormatException e) { throw new IncorrectDateException("Year parameter should be numeric."); } System.out.println("cur hour" + currentHour + " curr min" + currentMinute); System.out.println("begin time" + beginHour + " begin min" + beginMinute); if ((currentHour > beginHour) | ((currentHour == beginHour) & (currentMinute > beginMinute))) { if ((currentHour < endHour) | ((currentHour == endHour) & (currentMinute < endMinute))) { return true; } } return false; }
From source file:de.tor.tribes.ui.components.TimePicker.java
/** * Creates new form TimePicker//w w w . ja v a 2 s .co m */ public TimePicker(Date pDate) { Calendar cal = Calendar.getInstance(); if (pDate != null) { cal.setTime(pDate); } pHour = cal.get(Calendar.HOUR_OF_DAY); pMinute = cal.get(Calendar.MINUTE); initComponents(); initSpecialComponents(); }
From source file:net.sourceforge.eclipsetrader.borsaitalia.HistoryFeed.java
public void updateHistory(Security security, int interval) { History history = null;/*ww w. j a va 2 s. c om*/ Calendar from = Calendar.getInstance(); from.set(Calendar.MILLISECOND, 0); if (interval < IHistoryFeed.INTERVAL_DAILY) { history = security.getIntradayHistory(); from.set(Calendar.HOUR_OF_DAY, 0); from.set(Calendar.MINUTE, 0); from.set(Calendar.SECOND, 0); log.info("Updating intraday data for " + security.getCode() + " - " + security.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$ } else { history = security.getHistory(); if (history.size() == 0) from.add(Calendar.YEAR, -CorePlugin.getDefault().getPreferenceStore() .getInt(CorePlugin.PREFS_HISTORICAL_PRICE_RANGE)); else { Bar cd = history.getLast(); from.setTime(cd.getDate()); from.add(Calendar.DATE, 1); } log.info("Updating historical data for " + security.getCode() + " - " + security.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$ } String symbol = null; if (security.getHistoryFeed() != null) symbol = security.getHistoryFeed().getSymbol(); if (symbol == null || symbol.length() == 0) symbol = security.getCode(); String code = security.getCode(); if (code.indexOf('.') != -1) code = code.substring(0, code.indexOf('.')); try { String host = "194.185.192.223"; // "grafici.borsaitalia.it"; StringBuffer url = new StringBuffer( "http://" + host + "/scripts/cligipsw.dll?app=tic_d&action=dwnld4push&cod=" + code + "&codneb=" //$NON-NLS-1$//$NON-NLS-2$ + symbol + "&req_type=GRAF_DS&ascii=1&form_id="); if (interval < IHistoryFeed.INTERVAL_DAILY) url.append("&period=1MIN"); //$NON-NLS-1$ else { url.append("&period=1DAY"); //$NON-NLS-1$ url.append("&From=" + df.format(from.getTime())); //$NON-NLS-1$ } log.debug(url); HttpClient client = new HttpClient(); client.getHttpConnectionManager().getParams().setConnectionTimeout(5000); BundleContext context = BorsaitaliaPlugin.getDefault().getBundle().getBundleContext(); ServiceReference reference = context.getServiceReference(IProxyService.class.getName()); if (reference != null) { IProxyService proxy = (IProxyService) context.getService(reference); IProxyData data = proxy.getProxyDataForHost(host, IProxyData.HTTP_PROXY_TYPE); if (data != null) { if (data.getHost() != null) client.getHostConfiguration().setProxy(data.getHost(), data.getPort()); if (data.isRequiresAuthentication()) client.getState().setProxyCredentials(AuthScope.ANY, new UsernamePasswordCredentials(data.getUserId(), data.getPassword())); } } HttpMethod method = new GetMethod(url.toString()); method.setFollowRedirects(true); client.executeMethod(method); BufferedReader in = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream())); // The first line is the header, ignoring String inputLine = in.readLine(); log.trace(inputLine); while ((inputLine = in.readLine()) != null) { log.trace(inputLine); if (inputLine.startsWith("@") == true || inputLine.length() == 0) //$NON-NLS-1$ continue; String[] item = inputLine.split("\\|"); //$NON-NLS-1$ Bar bar = new Bar(); bar.setDate(df.parse(item[0])); bar.setOpen(Double.parseDouble(item[1])); bar.setHigh(Double.parseDouble(item[2])); bar.setLow(Double.parseDouble(item[3])); bar.setClose(Double.parseDouble(item[4])); bar.setVolume((long) Double.parseDouble(item[5])); // Remove the old bar, if exists int index = history.indexOf(bar.getDate()); if (index != -1) history.remove(index); history.add(bar); } in.close(); } catch (Exception e) { CorePlugin.logException(e); } CorePlugin.getRepository().save(history); }
From source file:com.ar.dev.tierra.api.dao.impl.NotaCreditoDAOImpl.java
@Override public List<NotaCredito> getDaily() { Criteria criteria = getSession().createCriteria(NotaCredito.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("idNotaCredito")); List<NotaCredito> list = criteria.list(); return list;/*from w w w .ja v a 2 s .c om*/ }
From source file:Main.java
private static String doFormatDate(Calendar calendar) { return String.format(Locale.ROOT, "%04d-%02d-%02dT%02d:%02d:%02dZ", calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND)); }