List of usage examples for java.util Calendar AM_PM
int AM_PM
To view the source code for java.util Calendar AM_PM.
Click Source Link
get
and set
indicating whether the HOUR
is before or after noon. From source file:org.apereo.portal.portlets.portletadmin.PortletDefinitionForm.java
public void setExpirationDateTime(Date expire) { if (expire != null) { this.setExpirationDate(expire); Calendar cal = Calendar.getInstance(); cal.setTime(expire);// w w w. j av a 2 s. com if (cal.get(Calendar.HOUR) == 0) { this.setExpirationHour(12); } else { this.setExpirationHour(cal.get(Calendar.HOUR)); } this.setExpirationMinute(cal.get(Calendar.MINUTE)); this.setExpirationAmPm(cal.get(Calendar.AM_PM)); } }
From source file:org.shengrui.oa.util.UtilDateTime.java
/** Makes a Timestamp for the beginning of the month * @return A Timestamp of the beginning of the month *//*from w ww . ja v a 2 s .c o m*/ public static java.sql.Timestamp monthBegin() { Calendar mth = Calendar.getInstance(); mth.set(Calendar.DAY_OF_MONTH, 1); mth.set(Calendar.HOUR_OF_DAY, 0); mth.set(Calendar.MINUTE, 0); mth.set(Calendar.SECOND, 0); mth.set(Calendar.AM_PM, Calendar.AM); return new java.sql.Timestamp(mth.getTime().getTime()); }
From source file:net.frontlinesms.plugins.reminders.RemindersDialogHandler.java
/** * Set date fields/*from ww w. j ava2 s . co m*/ * @param calendar * @param textDate * @param comboHour * @param comboMinute * @param comboAmPm */ private void setDateFields(Calendar calendar, Object textDate, Object comboHour, Object comboMinute, Object comboAmPm) { this.ui.setText(textDate, getDateStringFromCalendar(calendar)); if (calendar.get(Calendar.HOUR_OF_DAY) == 0) { this.ui.setSelectedIndex(comboHour, 11); } else if (calendar.get(Calendar.HOUR_OF_DAY) == 12) { this.ui.setSelectedIndex(comboHour, 11); } else if (calendar.get(Calendar.HOUR_OF_DAY) < 12) { this.ui.setSelectedIndex(comboHour, calendar.get(Calendar.HOUR_OF_DAY) - 1); } else if (calendar.get(Calendar.HOUR_OF_DAY) > 12) { this.ui.setSelectedIndex(comboHour, calendar.get(Calendar.HOUR_OF_DAY) - 13); } else { this.ui.setSelectedIndex(comboHour, 0); } this.ui.setSelectedIndex(comboMinute, calendar.get(Calendar.MINUTE)); this.ui.setSelectedIndex(comboAmPm, calendar.get(Calendar.AM_PM)); }
From source file:de.forsthaus.webui.logging.loginlog.SecLoginlogListCtrl.java
/** * when the "search/filter" button is clicked. It searches over a period. <br> * Checks if EndDate not before StartDate.<br> * /*from ww w.j a v a 2s.c om*/ * @param event */ public void onClick$button_SecLoginlogList_bb_SearchDate(Event event) throws Exception { if (!(this.dbox_LoginLog_DateFrom.getValue() == null) && !(this.dbox_LoginLog_DateTo.getValue() == null)) { if (this.dbox_LoginLog_DateFrom.getValue().after(this.dbox_LoginLog_DateTo.getValue())) { MultiLineMessageBox.doSetTemplate(); MultiLineMessageBox.show(Labels.getLabel("message_EndDate_Before_BeginDate")); } else { Date dateFrom = this.dbox_LoginLog_DateFrom.getValue(); Date dateTo = this.dbox_LoginLog_DateTo.getValue(); final Calendar calFrom = Calendar.getInstance(); calFrom.setTime(dateFrom); calFrom.set(Calendar.AM_PM, 0); calFrom.set(Calendar.HOUR, 0); calFrom.set(Calendar.MINUTE, 0); calFrom.set(Calendar.SECOND, 1); dateFrom = calFrom.getTime(); final Calendar calTo = Calendar.getInstance(); calTo.setTime(dateTo); calTo.set(Calendar.AM_PM, 1); calTo.set(Calendar.HOUR, 11); calTo.set(Calendar.MINUTE, 59); calTo.set(Calendar.SECOND, 59); dateTo = calTo.getTime(); // ++ create the searchObject and init sorting ++// final HibernateSearchObject<SecLoginlog> soSecLoginlog = new HibernateSearchObject<SecLoginlog>( SecLoginlog.class, getCountRows()); // deeper loading of the relations to prevent the lazy // loading problem. soSecLoginlog.addFetch("ip2Country.countryCode"); soSecLoginlog.addSort("lglLogtime", true); soSecLoginlog.addFilter(new Filter("lglLogtime", dateFrom, Filter.OP_GREATER_OR_EQUAL)); soSecLoginlog.addFilter(new Filter("lglLogtime", dateTo, Filter.OP_LESS_OR_EQUAL)); // Set the ListModel getPagedListWrapper().init(soSecLoginlog, this.listBoxSecUserlog, this.paging_SecUserLogList); this.checkbox_SecLoginlogList_ShowAll.setChecked(false); } } }
From source file:org.kuali.kfs.module.purap.document.service.impl.PurapServiceImpl.java
/** * @see org.kuali.kfs.module.purap.document.service.PurapService#isDateMoreThanANumberOfDaysAway(java.sql.Date, int) *//*from w w w. j a v a2 s . c o m*/ @Override public boolean isDateMoreThanANumberOfDaysAway(Date compareDate, int daysAway) { LOG.debug("isDateMoreThanANumberOfDaysAway() started"); Date todayAtMidnight = dateTimeService.getCurrentSqlDateMidnight(); Calendar daysAwayCalendar = dateTimeService.getCalendar(todayAtMidnight); daysAwayCalendar.add(Calendar.DATE, daysAway); Timestamp daysAwayTime = new Timestamp(daysAwayCalendar.getTime().getTime()); Calendar compareCalendar = dateTimeService.getCalendar(compareDate); compareCalendar.set(Calendar.HOUR, 0); compareCalendar.set(Calendar.MINUTE, 0); compareCalendar.set(Calendar.SECOND, 0); compareCalendar.set(Calendar.MILLISECOND, 0); compareCalendar.set(Calendar.AM_PM, Calendar.AM); Timestamp compareTime = new Timestamp(compareCalendar.getTime().getTime()); return (compareTime.compareTo(daysAwayTime) > 0); }
From source file:com.rogchen.common.xml.UtilDateTime.java
/** * Makes a Timestamp for the beginning of the month * * @return A Timestamp of the beginning of the month *//*from ww w. ja va 2s. c o m*/ public static Timestamp monthBegin() { Calendar mth = Calendar.getInstance(); mth.set(Calendar.DAY_OF_MONTH, 1); mth.set(Calendar.HOUR_OF_DAY, 0); mth.set(Calendar.MINUTE, 0); mth.set(Calendar.SECOND, 0); mth.set(Calendar.MILLISECOND, 0); mth.set(Calendar.AM_PM, Calendar.AM); return new Timestamp(mth.getTime().getTime()); }
From source file:org.foxbpm.calendar.mybatis.cmd.GetWorkCalendarEndTimeCmd.java
/** * ?/*from w w w . j av a2 s .c om*/ * @param calendarTypeEntity */ private void initCalendarType(CalendarTypeEntity calendarTypeEntity) { //ID? List<CalendarRuleEntity> calendarRuleEntities = workCalendarService .getCalendarRulesByTypeId(calendarTypeEntity.getId()); for (CalendarRuleEntity calendarRuleEntity : calendarRuleEntities) { //ID? List<CalendarPartEntity> calendarPartEntities = workCalendarService .getCalendarPartsByRuleId(calendarRuleEntity.getId()); //? Collections.sort(calendarPartEntities, new Comparator<CalendarPartEntity>() { public int compare(CalendarPartEntity o1, CalendarPartEntity o2) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("hh:mm"); long o1s = 0; long o2s = 0; Calendar calendar = Calendar.getInstance(); Date o1d = null; try { o1d = simpleDateFormat.parse(o1.getStarttime()); } catch (ParseException e) { throw new FoxBPMIllegalArgumentException( "???HH:mm,?" + o1.getStarttime()); } calendar.setTime(o1d); //"120??" if (o1.getStarttime().equals("12:00")) { calendar.set(Calendar.AM_PM, 1); } else if (o1.getStarttime().equals("00:00")) { calendar.set(Calendar.AM_PM, 0); } else { calendar.set(Calendar.AM_PM, o1.getAmorpm()); } o1s = calendar.getTimeInMillis(); Date o2d = null; try { o2d = simpleDateFormat.parse(o2.getStarttime()); } catch (ParseException e) { throw new FoxBPMIllegalArgumentException( "???HH:mm,?" + o2.getStarttime()); } calendar.setTime(o2d); //"120??" if (o2.getStarttime().equals("12:00")) { calendar.set(Calendar.AM_PM, 1); } else if (o2.getStarttime().equals("00:00")) { calendar.set(Calendar.AM_PM, 0); } else { calendar.set(Calendar.AM_PM, o2.getAmorpm()); } o2s = calendar.getTimeInMillis(); calendar.getTime(); return o1s < o2s == true ? 0 : 1; } }); calendarRuleEntity.setCalendarPartEntities(calendarPartEntities); } calendarTypeEntity.setCalendarRuleEntities(calendarRuleEntities); }
From source file:com.eryansky.common.utils.DateUtil.java
/** * Calendar?/*from ww w. j ava 2 s. c om*/ */ public static long getLongTime(Calendar yourCalendar) { try { long longCalendar = 0; // String strYear = String.valueOf(yourCalendar.get(Calendar.YEAR)); String strMonth = String.valueOf(yourCalendar.get(Calendar.MONTH) + 1); String strDate = String.valueOf(yourCalendar.get(Calendar.DATE)); String strHour = String.valueOf(yourCalendar.get(Calendar.HOUR)); String strAM_PM = String.valueOf(yourCalendar.get(Calendar.AM_PM)); String strMinute = String.valueOf(yourCalendar.get(Calendar.MINUTE)); String strSecond = String.valueOf(yourCalendar.get(Calendar.SECOND)); // ?24? // strAM_PM=="1",??strHour?12 if (strAM_PM.equals("1")) { strHour = String.valueOf(Long.parseLong(strHour) + 12); } // ?? if (strMonth.length() < 2) { strMonth = "0" + strMonth; } if (strDate.length() < 2) { strDate = "0" + strDate; } if (strHour.length() < 2) { strHour = "0" + strHour; } if (strMinute.length() < 2) { strMinute = "0" + strMinute; } if (strSecond.length() < 2) { strSecond = "0" + strSecond; } // ? longCalendar = Long.parseLong(strYear + strMonth + strDate + strHour + strMinute + strSecond); // ? return longCalendar; } catch (Exception Exp) { return 0; } }
From source file:org.apache.orc.impl.mask.RedactMaskFactory.java
/** * Given the requested masking parameters, redact the given time * @param millis the original time/*from w w w. j a v a 2 s .c o m*/ * @return the millis after it has been masked */ long maskTime(long millis) { scratch.setTimeInMillis(millis); if (YEAR_REPLACEMENT != UNMASKED_DATE) { scratch.set(Calendar.YEAR, YEAR_REPLACEMENT); } if (MONTH_REPLACEMENT != UNMASKED_DATE) { scratch.set(Calendar.MONTH, MONTH_REPLACEMENT - 1); } if (DATE_REPLACEMENT != UNMASKED_DATE) { scratch.set(Calendar.DATE, DATE_REPLACEMENT); } if (HOUR_REPLACEMENT != UNMASKED_DATE) { if (HOUR_REPLACEMENT >= 12) { scratch.set(Calendar.HOUR, HOUR_REPLACEMENT - 12); scratch.set(Calendar.AM_PM, Calendar.PM); } else { scratch.set(Calendar.HOUR, HOUR_REPLACEMENT); scratch.set(Calendar.AM_PM, Calendar.AM); } } if (MINUTE_REPLACEMENT != UNMASKED_DATE) { scratch.set(Calendar.MINUTE, MINUTE_REPLACEMENT); } if (SECOND_REPLACEMENT != UNMASKED_DATE) { scratch.set(Calendar.SECOND, SECOND_REPLACEMENT); scratch.set(Calendar.MILLISECOND, 0); } return scratch.getTimeInMillis(); }
From source file:org.foxbpm.calendar.mybatis.cmd.GetWorkCalendarEndTimeCmd.java
/** * ?/*www .j a v a 2s .c o m*/ * @param date * @param amorpm * @return * @throws ParseException */ private long getCalculateTime(String date, int amorpm) { Date startDate = null; try { startDate = timeFormat.parse(date); } catch (ParseException ex) { throw new FoxBPMIllegalArgumentException( "???HH:mm,?" + date); } Calendar formatCalendar = Calendar.getInstance(); formatCalendar.setTime(startDate); formatCalendar.set(Calendar.YEAR, year); formatCalendar.set(Calendar.MONTH, month - 1); formatCalendar.set(Calendar.DATE, day); //"120??" if (date.equals("12:00")) { formatCalendar.set(Calendar.AM_PM, 1); } else if (date.equals("00:00")) { formatCalendar.set(Calendar.AM_PM, 0); } else { formatCalendar.set(Calendar.AM_PM, amorpm); } // long startTime = formatCalendar.getTimeInMillis(); return startTime; }