List of usage examples for java.util Calendar HOUR
int HOUR
To view the source code for java.util Calendar HOUR.
Click Source Link
get
and set
indicating the hour of the morning or afternoon. From source file:com.ecofactor.qa.automation.api.ReportsAPITest.java
/** * User savings./* ww w.ja va 2s . c om*/ */ @Test(groups = { "sanity1" }) public void userSavings() { String id = reportsAPIConfig.get(ReportsAPIConfig.USER_ID); String content = HttpUtil.get(getUserSavingsURL(id), getNotAccumulatedParams(5), 200); JSONObject object = JsonUtil.parseObject(content); Calendar start = DateUtil.getUTCCalendar(); start.set(Calendar.MONTH, 5 - 1); start.set(Calendar.DATE, 1); start.set(Calendar.HOUR, 0); start.set(Calendar.MINUTE, 0); start.set(Calendar.SECOND, 0); Calendar end = DateUtil.getUTCCalendar(); end.set(Calendar.MONTH, 5 - 1); end.set(Calendar.DATE, end.getMaximum(Calendar.DATE)); end.set(Calendar.HOUR, 23); end.set(Calendar.MINUTE, 59); end.set(Calendar.SECOND, 0); assertUserSavingsData(object, start, end); }
From source file:com.ecofactor.qa.automation.api.HttpsReportsAPITest.java
/** * User savings.//from ww w. j av a 2 s . c o m */ @Test(groups = { "sanity1" }) public void userSavings() { String id = reportsAPIConfig.get(HttpsReportsAPIConfig.USER_ID); String content = HttpsUtil.get(getUserSavingsURL(id), getNotAccumulatedParams(5), 200); JSONObject object = JsonUtil.parseObject(content); Calendar start = DateUtil.getUTCCalendar(); start.set(Calendar.MONTH, 5 - 1); start.set(Calendar.DATE, 1); start.set(Calendar.HOUR, 0); start.set(Calendar.MINUTE, 0); start.set(Calendar.SECOND, 0); Calendar end = DateUtil.getUTCCalendar(); end.set(Calendar.MONTH, 5 - 1); end.set(Calendar.DATE, end.getMaximum(Calendar.DATE)); end.set(Calendar.HOUR, 23); end.set(Calendar.MINUTE, 59); end.set(Calendar.SECOND, 0); assertUserSavingsData(object, start, end); }
From source file:com.ecofactor.qa.automation.api.ReportsAPITest.java
/** * User savings accumulated./*from w ww . j av a2 s . c o m*/ */ @Test(groups = { "sanity1" }) public void userSavingsAccumulated() { String id = reportsAPIConfig.get(ReportsAPIConfig.USER_ID); String content = HttpUtil.get(getUserSavingsURL(id), getAccumulatedParams(5), 200); JSONObject object = JsonUtil.parseObject(content); Calendar start = DateUtil.getUTCCalendar(); start.set(Calendar.MONTH, 5 - 1); start.set(Calendar.DATE, 1); start.set(Calendar.HOUR, 0); start.set(Calendar.MINUTE, 0); start.set(Calendar.SECOND, 0); Calendar end = DateUtil.getUTCCalendar(); end.set(Calendar.MONTH, 5 - 1); end.set(Calendar.DATE, end.getMaximum(Calendar.DATE)); end.set(Calendar.HOUR, 23); end.set(Calendar.MINUTE, 59); end.set(Calendar.SECOND, 0); assertAccumulatedUserSavingsData(object, start, end); }
From source file:com.gongpingjia.carplay.service.impl.ActivityServiceImpl.java
private void initAndSaveStatisticActivityReMatch(HttpServletRequest request, ActivityQueryParam param, String eventType) {//from w w w . j av a 2 s . c o m StatisticActivityMatch statisticActivityMatch = new StatisticActivityMatch(); statisticActivityMatch.setType(param.getType()); statisticActivityMatch.setMajorType(param.getMajorType()); statisticActivityMatch.setPay(param.getPay()); Address address = new Address(); address.setProvince(param.getProvince()); address.setCity(param.getCity()); address.setDistrict(param.getDistrict()); statisticActivityMatch.setDestination(address); Landmark landmark = new Landmark(); landmark.setLongitude(param.getLongitude()); landmark.setLatitude(param.getLatitude()); statisticActivityMatch.setDestPoint(landmark); statisticActivityMatch.setTransfer(param.getTransfer()); statisticActivityMatch.setUserId(param.getUserId()); statisticActivityMatch.setIp(IPFetchUtil.getIPAddress(request)); statisticActivityMatch.setEvent(eventType); statisticActivityMatch.setCount(1); Date currentTime = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(currentTime); statisticActivityMatch.setCreateTime(currentTime.getTime()); statisticActivityMatch.setYear(calendar.get(Calendar.YEAR)); statisticActivityMatch.setMonth(calendar.get(Calendar.MONTH) + 1); statisticActivityMatch.setDay(calendar.get(Calendar.DAY_OF_MONTH) + 1); statisticActivityMatch.setHour(calendar.get(Calendar.HOUR)); statisticActivityMatch.setMinute(calendar.get(Calendar.MINUTE)); statisticActivityMatchDao.save(statisticActivityMatch); }
From source file:com.wso2telco.core.dbutils.DbService.java
public SpendLimitDAO getGroupTotalDayAmount(String groupName, String operator, String msisdn) throws DBUtilException { Connection con = null;// w w w. j av a 2 s .co m PreparedStatement ps = null; ResultSet rs = null; SpendLimitDAO spendLimitDAO = null; try { con = DbUtils.getDBConnection(); Calendar calendarFrom = Calendar.getInstance(); calendarFrom.set(Calendar.AM_PM, Calendar.AM); calendarFrom.set(Calendar.HOUR, 00); calendarFrom.set(Calendar.MINUTE, 00); calendarFrom.set(Calendar.SECOND, 00); calendarFrom.set(Calendar.MILLISECOND, 00); Calendar calendarTo = Calendar.getInstance(); calendarTo.set(Calendar.AM_PM, Calendar.PM); calendarTo.set(Calendar.HOUR, 11); calendarTo.set(Calendar.MINUTE, 59); calendarTo.set(Calendar.SECOND, 59); calendarTo.set(Calendar.MILLISECOND, 999); String sql = "SELECT SUM(amount) AS amount " + "FROM spendlimitdata " + "where effectiveTime between ? and ? " + "and groupName=? " + "and operatorId=? " + "and msisdn=? " + "group by groupName, operatorId, msisdn"; ps = con.prepareStatement(sql); ps.setLong(1, calendarFrom.getTimeInMillis()); ps.setLong(2, calendarTo.getTimeInMillis()); ps.setString(3, groupName); ps.setString(4, operator); ps.setString(5, msisdn); rs = ps.executeQuery(); if (rs.next()) { spendLimitDAO = new SpendLimitDAO(); spendLimitDAO.setAmount(rs.getDouble("amount")); } } catch (Exception e) { DbUtils.handleException("Error while checking Operator Spend Limit. ", e); } finally { DbUtils.closeAllConnections(ps, con, rs); } return spendLimitDAO; }
From source file:com.ecofactor.qa.automation.api.HttpsReportsAPITest.java
/** * User savings accumulated./*from ww w .j av a2s . c o m*/ */ @Test(groups = { "sanity1" }) public void userSavingsAccumulated() { String id = reportsAPIConfig.get(HttpsReportsAPIConfig.USER_ID); String content = HttpsUtil.get(getUserSavingsURL(id), getAccumulatedParams(5), 200); JSONObject object = JsonUtil.parseObject(content); Calendar start = DateUtil.getUTCCalendar(); start.set(Calendar.MONTH, 5 - 1); start.set(Calendar.DATE, 1); start.set(Calendar.HOUR, 0); start.set(Calendar.MINUTE, 0); start.set(Calendar.SECOND, 0); Calendar end = DateUtil.getUTCCalendar(); end.set(Calendar.MONTH, 5 - 1); end.set(Calendar.DATE, end.getMaximum(Calendar.DATE)); end.set(Calendar.HOUR, 23); end.set(Calendar.MINUTE, 59); end.set(Calendar.SECOND, 0); assertAccumulatedUserSavingsData(object, start, end); }
From source file:cx.fbn.nevernote.sql.REnSearch.java
public int dateCheck(String date, long noteDate) throws java.lang.NumberFormatException { int offset = 0; boolean found = false; GregorianCalendar calendar = new GregorianCalendar(); if (date.contains("-")) { String modifier = date.substring(date.indexOf("-") + 1); offset = new Integer(modifier); offset = 0 - offset;/*w ww .ja va 2s .c o m*/ date = date.substring(0, date.indexOf("-")); } if (date.contains("+")) { String modifier = date.substring(date.indexOf("+") + 1); offset = new Integer(modifier); date = date.substring(0, date.indexOf("+")); } if (date.equalsIgnoreCase("today")) { calendar.add(Calendar.DATE, offset); calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 1); found = true; } if (date.equalsIgnoreCase("month")) { calendar.add(Calendar.MONTH, offset); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 1); found = true; } if (date.equalsIgnoreCase("year")) { calendar.add(Calendar.YEAR, offset); calendar.set(Calendar.MONTH, Calendar.JANUARY); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 1); found = true; } if (date.equalsIgnoreCase("week")) { calendar.add(Calendar.DATE, 0 - calendar.get(Calendar.DAY_OF_WEEK) + 1); calendar.add(Calendar.DATE, (offset * 7)); calendar.set(Calendar.HOUR, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 1); found = true; } // If nothing was found, then we have a date number if (!found) { calendar = stringToGregorianCalendar(date); } String dateTimeFormat = new String("yyyyMMdd-HHmmss"); SimpleDateFormat simple = new SimpleDateFormat(dateTimeFormat); StringBuilder creationDate = new StringBuilder(simple.format(noteDate)); GregorianCalendar nCalendar = stringToGregorianCalendar(creationDate.toString().replace("-", "T")); if (calendar == null || nCalendar == null) // If we have something invalid, it automatically fails return 1; return calendar.compareTo(nCalendar); }
From source file:DateFormatUtils.java
/** * <p>Returns a list of Rules given a pattern.</p> * /*from w ww . jav a 2s . c o m*/ * @return a <code>List</code> of Rule objects * @throws IllegalArgumentException if pattern is invalid */ protected List parsePattern() { DateFormatSymbols symbols = new DateFormatSymbols(mLocale); List rules = new ArrayList(); String[] ERAs = symbols.getEras(); String[] months = symbols.getMonths(); String[] shortMonths = symbols.getShortMonths(); String[] weekdays = symbols.getWeekdays(); String[] shortWeekdays = symbols.getShortWeekdays(); String[] AmPmStrings = symbols.getAmPmStrings(); int length = mPattern.length(); int[] indexRef = new int[1]; for (int i = 0; i < length; i++) { indexRef[0] = i; String token = parseToken(mPattern, indexRef); i = indexRef[0]; int tokenLen = token.length(); if (tokenLen == 0) { break; } Rule rule; char c = token.charAt(0); switch (c) { case 'G': // era designator (text) rule = new TextField(Calendar.ERA, ERAs); break; case 'y': // year (number) if (tokenLen >= 4) { rule = selectNumberRule(Calendar.YEAR, tokenLen); } else { rule = TwoDigitYearField.INSTANCE; } break; case 'M': // month in year (text and number) if (tokenLen >= 4) { rule = new TextField(Calendar.MONTH, months); } else if (tokenLen == 3) { rule = new TextField(Calendar.MONTH, shortMonths); } else if (tokenLen == 2) { rule = TwoDigitMonthField.INSTANCE; } else { rule = UnpaddedMonthField.INSTANCE; } break; case 'd': // day in month (number) rule = selectNumberRule(Calendar.DAY_OF_MONTH, tokenLen); break; case 'h': // hour in am/pm (number, 1..12) rule = new TwelveHourField(selectNumberRule(Calendar.HOUR, tokenLen)); break; case 'H': // hour in day (number, 0..23) rule = selectNumberRule(Calendar.HOUR_OF_DAY, tokenLen); break; case 'm': // minute in hour (number) rule = selectNumberRule(Calendar.MINUTE, tokenLen); break; case 's': // second in minute (number) rule = selectNumberRule(Calendar.SECOND, tokenLen); break; case 'S': // millisecond (number) rule = selectNumberRule(Calendar.MILLISECOND, tokenLen); break; case 'E': // day in week (text) rule = new TextField(Calendar.DAY_OF_WEEK, tokenLen < 4 ? shortWeekdays : weekdays); break; case 'D': // day in year (number) rule = selectNumberRule(Calendar.DAY_OF_YEAR, tokenLen); break; case 'F': // day of week in month (number) rule = selectNumberRule(Calendar.DAY_OF_WEEK_IN_MONTH, tokenLen); break; case 'w': // week in year (number) rule = selectNumberRule(Calendar.WEEK_OF_YEAR, tokenLen); break; case 'W': // week in month (number) rule = selectNumberRule(Calendar.WEEK_OF_MONTH, tokenLen); break; case 'a': // am/pm marker (text) rule = new TextField(Calendar.AM_PM, AmPmStrings); break; case 'k': // hour in day (1..24) rule = new TwentyFourHourField(selectNumberRule(Calendar.HOUR_OF_DAY, tokenLen)); break; case 'K': // hour in am/pm (0..11) rule = selectNumberRule(Calendar.HOUR, tokenLen); break; case 'z': // time zone (text) if (tokenLen >= 4) { rule = new TimeZoneNameRule(mTimeZone, mTimeZoneForced, mLocale, TimeZone.LONG); } else { rule = new TimeZoneNameRule(mTimeZone, mTimeZoneForced, mLocale, TimeZone.SHORT); } break; case 'Z': // time zone (value) if (tokenLen == 1) { rule = TimeZoneNumberRule.INSTANCE_NO_COLON; } else { rule = TimeZoneNumberRule.INSTANCE_COLON; } break; case '\'': // literal text String sub = token.substring(1); if (sub.length() == 1) { rule = new CharacterLiteral(sub.charAt(0)); } else { rule = new StringLiteral(sub); } break; default: throw new IllegalArgumentException("Illegal pattern component: " + token); } rules.add(rule); } return rules; }
From source file:com.concursive.connect.web.modules.calendar.utils.CalendarView.java
/** * Constructs the calendar and returns a String object with the HTML * * @return The HTML value/*w ww . java2 s . c o m*/ */ public String getHtml(String contextPath) { StringBuffer html = new StringBuffer(); //Begin the whole table html.append("<table class='calendarContainer'>" + "<tr><td>"); //Space at top to match if (headerSpace) { html.append("<table width=\"100%\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\">" + "<tr><td> </td></tr>" + "</table>"); } String monthArrowPrev = ""; String monthArrowNext = ""; //If popup, then use small formats of each class String tableWidth = "100%"; String pre = ""; if (popup) { pre = "small"; tableWidth = "155"; } else if (frontPageView) { tableWidth = "auto"; } //Display Calendar html.append("<table height=\"100%\" width='" + tableWidth + "' " + borderSize + cellSpacing + cellPadding + " class='" + pre + "calendar' id='calendarTable'>" + "<tr height=\"4%\">"); //Display Previous Month Arrow if (popup) { monthArrowPrev = "<INPUT TYPE=\"IMAGE\" NAME=\"prev\" ALIGN=\"MIDDLE\" SRC=\"" + contextPath + "/images/calendar/prev_arrow.png\">"; monthArrowNext = "<INPUT TYPE=\"IMAGE\" NAME=\"next\" ALIGN=\"MIDDLE\" SRC=\"" + contextPath + "/images/calendar/next_arrow.png\">"; if (monthArrows) { html.append("<th class='" + pre + "monthArrowPrev'>" + monthArrowPrev + "</th>"); } //Display Current Month name if (monthArrows) { html.append("<th colspan='5' "); } else { html.append("<th colspan='7' "); } html.append("class='" + pre + "monthName'"); html.append("><strong>" + StringUtils.toHtml(this.getMonthName(cal)) + " " + this.getYear(cal) + "</strong></th>"); //Display Next Month Arrow if (monthArrows) { html.append("<th class='" + pre + "monthArrowNext'>" + monthArrowNext + "</th>"); } } else { if (monthArrows) { int prevMonth = calPrev.get(Calendar.MONTH) + 1; String previousLink = calPrev.get(Calendar.YEAR) + "-" + (prevMonth < 10 ? "0" : "") + prevMonth; int nextMonth = calNext.get(Calendar.MONTH) + 1; String nextLink = calNext.get(Calendar.YEAR) + "-" + (nextMonth < 10 ? "0" : "") + nextMonth; html.append("<th colspan='8' "); html.append("class='" + pre + "monthName'"); html.append(">" + "<a href=\"javascript:goToMonth('" + previousLink + "');\"><img ALIGN=\"MIDDLE\" border=\"0\" src=\"" + contextPath + "/images/calendar/prev_arrow.png\" /></a> " + "<strong>" + StringUtils.toHtml(this.getMonthName(cal)) + " " + this.getYear(cal) + "</strong>" + " <a href=\"javascript:goToMonth('" + nextLink + "');\"><img ALIGN=\"MIDDLE\" border=\"0\" src=\"" + contextPath + "/images/calendar/next_arrow.png\" /></a>" + "</th>"); } else { html.append("<th colspan=\"8\">"); html.append(getHtmlMonthSelect()); html.append(" "); html.append(getHtmlYearSelect()); html.append(" "); Calendar tmp = Calendar.getInstance(locale); tmp.set(Calendar.HOUR, 0); tmp.set(Calendar.MINUTE, 0); tmp.set(Calendar.SECOND, 0); tmp.set(Calendar.MILLISECOND, 0); if (timeZone != null) { tmp.setTimeZone(timeZone); } html.append("<a href=\"javascript:showToDaysEvents('" + (tmp.get(Calendar.MONTH) + 1) + "','" + tmp.get(Calendar.DATE) + "','" + tmp.get(Calendar.YEAR) + "');\">Today</a>"); html.append("</th>"); } } html.append("</tr>"); //Display the Days of the Week names html.append("<tr height=\"4%\">"); if (!popup) { html.append("<td width=\"4\" class=\"row1\"><font style=\"visibility:hidden\">n</font></td>"); } // Use locale... int firstDayOfWeek = cal.getFirstDayOfWeek(); for (int i = firstDayOfWeek; i < firstDayOfWeek + 7; i++) { html.append("<td width=\"14%\" class='" + pre + "weekName'>"); if (popup || frontPageView) { html.append(StringUtils.toHtml(this.getDayName(i, true))); } else { html.append(StringUtils.toHtml(this.getDayName(i, false))); } html.append("</td>"); } html.append("</tr>"); int startCellPrev = this.getStartCell(calPrev); int endCellPrev = this.getEndCell(calPrev); int startCell = this.getStartCell(cal); int endCell = this.getEndCell(cal); int thisDay = 1; String tdClass = ""; for (int cellNo = 0; cellNo < this.getNumberOfCells(); cellNo++) { boolean prevMonth = false; boolean nextMonth = false; boolean mainMonth = false; int displayDay = 0; int displayMonth = 0; int displayYear = 0; if (cellNo < startCell) { //The previous month displayMonth = calPrev.get(Calendar.MONTH) + 1; displayYear = calPrev.get(Calendar.YEAR); displayDay = (endCellPrev - startCell + 2 + cellNo - startCellPrev); prevMonth = true; } else if (cellNo > endCell) { //The next month displayMonth = calNext.get(Calendar.MONTH) + 1; displayYear = calNext.get(Calendar.YEAR); if (endCell + 1 == cellNo) { thisDay = 1; } displayDay = thisDay; nextMonth = true; thisDay++; } else { //The main month mainMonth = true; displayMonth = cal.get(Calendar.MONTH) + 1; displayYear = cal.get(Calendar.YEAR); displayDay = thisDay; thisDay++; } if (cellNo % 7 == 0) { tdClass = ""; html.append("<tr"); if (!popup) { if (calendarInfo.getCalendarView().equalsIgnoreCase("week")) { if (displayMonth == calendarInfo.getStartMonthOfWeek() && displayDay == calendarInfo.getStartDayOfWeek()) { html.append(" class=\"selectedWeek\" "); tdClass = "selectedDay"; } } } html.append(">"); } if (!popup && (cellNo % 7 == 0)) { html.append("<td valign='top' width=\"4\" class=\"weekSelector\" name=\"weekSelector\">"); String weekSelectedArrow = "<a href=\"javascript:showWeekEvents('" + displayYear + "','" + displayMonth + "','" + displayDay + "')\">" + "<img ALIGN=\"MIDDLE\" src=\"" + contextPath + "/images/control.png\" border=\"0\" onclick=\"javascript:switchTableClass(this,'selectedWeek','row');\"></a>"; html.append(weekSelectedArrow); html.append("</td>"); } html.append("<td valign='top'"); if (!smallView) { if (!frontPageView) { html.append(" height='70'"); } else { html.append(" height='35'"); } } if (!popup) { html.append(" onclick=\"javascript:showDayEvents('" + displayYear + "','" + displayMonth + "','" + displayDay + "');javascript:switchTableClass(this,'selectedDay','cell');\""); if (calendarInfo.getCalendarView().equalsIgnoreCase("day")) { tdClass = ""; if (displayMonth == calendarInfo.getMonthSelected() && displayDay == calendarInfo.getDaySelected()) { tdClass = "selectedDay"; } } } if (prevMonth) { //The previous month if (this.isCurrentDay(calPrev, displayDay)) { html.append(" id='today' class='" + ((tdClass.equalsIgnoreCase("")) ? pre + "today'" : tdClass + "'") + " name='" + pre + "today' >"); } else { html.append(" class='" + ((tdClass.equalsIgnoreCase("")) ? pre + "noday'" : tdClass + "'") + " name='" + pre + "noday' >"); } } else if (nextMonth) { if (this.isCurrentDay(calNext, displayDay)) { html.append(" id='today' class='" + ((tdClass.equalsIgnoreCase("")) ? pre + "today'" : tdClass + "'") + " name='" + pre + "today' >"); } else { html.append(" class='" + ((tdClass.equalsIgnoreCase("")) ? pre + "noday'" : tdClass + "'") + " name='" + pre + "noday' >"); } } else { //The main main if (this.isCurrentDay(cal, displayDay)) { html.append(" id='today' class='" + ((tdClass.equalsIgnoreCase("")) ? pre + "today'" : tdClass + "'") + " name='" + pre + "today' >"); } else { html.append(" class='" + ((tdClass.equalsIgnoreCase("")) ? pre + "day'" : tdClass + "'") + " name='" + pre + "day' >"); } } // end if block //Display the day in the appropriate link color if (popup) { //Popup calendar CalendarEventList highlightEvent = eventList .get(displayMonth + "/" + displayDay + "/" + displayYear); String dateColor = "" + displayDay; if (highlightEvent != null && highlightEvent.containsKey("highlight")) { dateColor = "<font color=#FF0000>" + displayDay + "</font>"; } else if (!mainMonth) { dateColor = "<font color=#888888>" + displayDay + "</font>"; } html.append("<a href=\"javascript:returnDate(" + displayDay + ", " + displayMonth + ", " + displayYear + ");\"" + ">" + dateColor + "</a>"); } else { //Event calendar String dateColor = "" + displayDay; if (!mainMonth) { dateColor = "<font color=#888888>" + displayDay + "</font>"; } html.append("<a href=\"javascript:showDayEvents('" + displayYear + "','" + displayMonth + "','" + displayDay + "');\">" + dateColor + "</a>"); if (this.isHoliday(String.valueOf(displayMonth), String.valueOf(displayDay), String.valueOf(displayYear))) { html.append(CalendarEvent.getIcon("holiday", contextPath) + "<font color=\"blue\"><br />"); } //get all events categories and respective counts. HashMap events = this.getEventList(String.valueOf(displayMonth), String.valueOf(displayDay), String.valueOf(displayYear)); if (events.size() > 0) { html.append( "<table width=\"12%\" align=\"center\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" class=\"dayIcon\">"); for (int i = 0; i < Array.getLength(CalendarEventList.EVENT_TYPES); i++) { String eventType = CalendarEventList.EVENT_TYPES[i]; if (events.containsKey(eventType)) { if (!eventType.equals(CalendarEventList.EVENT_TYPES[7])) { Object eventObj = events.get(eventType); // use reflection to call the size method on the event list object String eventSize = (String) ObjectUtils.getObject(eventObj, "sizeString"); if (!eventSize.equals("0")) { html.append("<tr><td>" + CalendarEvent.getIcon(eventType, contextPath) + "</td><td> " + eventSize + "</td></tr>"); } } } } html.append("</table>"); } //end of events display. } html.append("</td>"); if ((cellNo + 1) % 7 == 0) { html.append("</tr>"); } // end check for end of row } // end for-loop html.append("</table></td></tr>"); html.append("</table>"); //Display a link that selects today if (popup) { Calendar tmp = Calendar.getInstance(locale); tmp.set(Calendar.HOUR, 0); tmp.set(Calendar.MINUTE, 0); tmp.set(Calendar.SECOND, 0); tmp.set(Calendar.MILLISECOND, 0); if (timeZone != null) { tmp.setTimeZone(timeZone); } int displayMonth = tmp.get(Calendar.MONTH) + 1; int displayYear = tmp.get(Calendar.YEAR); int displayDay = tmp.get(Calendar.DAY_OF_MONTH); html.append("<p class=\"smallfooter\">Today: " + "<a href=\"javascript:returnDate(" + displayDay + ", " + displayMonth + ", " + displayYear + ");\"" + ">" + this.getToday() + "</p>"); html.append("<input type=\"hidden\" name=\"year\" value=\"" + cal.get(Calendar.YEAR) + "\">"); html.append("<input type=\"hidden\" name=\"month\" value=\"" + (cal.get(Calendar.MONTH) + 1) + "\">"); } html.append("<input type=\"hidden\" name=\"day\" value=\"" + (cal.get(Calendar.DATE)) + "\">"); return html.toString(); }
From source file:com.mb.framework.util.DateTimeUtil.java
/** * This method is used for// w w w.j av a 2s. c o m * * @param date * @return */ public static int getHour(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return calendar.get(Calendar.HOUR); }