@Test public void timestamp() throws SQLException { connectWithJulianDayModeActivated(); long now = System.currentTimeMillis(); Timestamp d1 = new Timestamp(now); Date d2 = new Date(now); Time d3 = new Time(now); stat.execute("create table t (c1);"); PreparedStatement prep = conn.prepareStatement("insert into t values (?);"); prep.setTimestamp(1, d1); prep.executeUpdate(); ResultSet rs = stat.executeQuery("select c1 from t;"); assertTrue(rs.next()); assertEquals(d1, rs.getTimestamp(1)); rs = stat.executeQuery("select date(c1, 'localtime') from t;"); assertTrue(rs.next()); assertEquals(d2.toString(), rs.getString(1)); rs = stat.executeQuery("select time(c1, 'localtime') from t;"); assertTrue(rs.next()); assertEquals(d3.toString(), rs.getString(1)); rs = stat.executeQuery("select strftime('%Y-%m-%d %H:%M:%f', c1, 'localtime') from t;"); assertTrue(rs.next()); // assertEquals(d1.toString(), rs.getString(1)); // ms are not occurate... }
public void testGetDateFromBrowser() throws Exception { // test that day and month order is correct long expectedDate = new DateMidnight(2005, 03, 04).getMillis(); java.sql.Date result = DateUtils.getDateAsSentFromBrowser("04/03/2005"); Assert.assertEquals(expectedDate, result.getTime()); expectedDate = new DateMidnight(2005, 04, 03).getMillis(); result = DateUtils.getDateAsSentFromBrowser("3/4/2005"); Assert.assertEquals(expectedDate, result.getTime()); // test non-lenient day/month parsing (must be in the normal range, i.e. // 1-12 for months) String badDate = "3/15/2006"; try { result = DateUtils.getDateAsSentFromBrowser(badDate); Assert.fail(); } catch (InvalidDateException e) { Assert.assertEquals(badDate, e.getDateString()); } // test acceptance of two-digit years expectedDate = new DateMidnight(2005, 5, 5).getMillis(); result = DateUtils.getDateAsSentFromBrowser("5/5/05"); Assert.assertEquals(expectedDate, result.getTime()); }
protected java.sql.Date getOrAddDate(long longKey) { java.sql.Date testValue; int hash = (int) longKey ^ (int) (longKey >>> 32); int index = hashIndex.getHashIndex(hash); int lookup = hashIndex.hashTable[index]; int lastLookup = -1; for (; lookup >= 0; lastLookup = lookup, lookup = hashIndex.getNextLookup(lookup)) { testValue = (java.sql.Date) objectKeyTable[lookup]; if (testValue.getTime() == longKey) { accessTable[lookup] = accessCount++; return testValue; } } if (hashIndex.elementCount >= threshold) { reset(); return getOrAddDate(longKey); } lookup = hashIndex.linkNode(index, lastLookup); testValue = new java.sql.Date(longKey); objectKeyTable[lookup] = testValue; accessTable[lookup] = accessCount++; return testValue; }
/** * Manipulates a PDF file src with the file dest as result * * @param src the original PDF * @param dest the resulting PDF * @throws IOException * @throws DocumentException * @throws SQLException */ public void manipulatePdf(String src, String dest) throws IOException, DocumentException, SQLException { // Create a database connection DatabaseConnection connection = new HsqldbConnection("filmfestival"); // Create a list with bookmarks ArrayList<HashMap<String, Object>> outlines = new ArrayList<HashMap<String, Object>>(); HashMap<String, Object> map = new HashMap<String, Object>(); outlines.add(map); map.put("Title", "Calendar"); ArrayList<HashMap<String, Object>> kids = new ArrayList<HashMap<String, Object>>(); map.put("Kids", kids); int page = 1; List<Date> days = PojoFactory.getDays(connection); for (Date day : days) { HashMap<String, Object> kid = new HashMap<String, Object>(); kids.add(kid); kid.put("Title", day.toString()); kid.put("Action", "GoTo"); kid.put("Page", String.format("%d Fit", page++)); } // Create a reader PdfReader reader = new PdfReader(src); // Create a stamper PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); stamper.setOutlines(outlines); // Close the stamper stamper.close(); reader.close(); // Close the database connection connection.close(); }
private static Date getDate(SQLDialect dialect, ResultSet rs, int index) throws SQLException { // SQLite's type affinity needs special care... if (dialect == SQLDialect.SQLITE) { String date = rs.getString(index); if (date != null) { return new Date(parse("yyyy-MM-dd", date)); } return null; } // Cubrid SQL dates are incorrectly fetched. Reset milliseconds... // See http://jira.cubrid.org/browse/APIS-159 // See https://sourceforge.net/apps/trac/cubridinterface/ticket/140 else if (dialect == CUBRID) { Date date = rs.getDate(index); if (date != null) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(date.getTime()); cal.set(Calendar.MILLISECOND, 0); date = new Date(cal.getTimeInMillis()); } return date; } else { return rs.getDate(index); } }
/** * 根据所给的起止时间来计算间隔的天数 * * @param startDate 起始时间 * @param endDate 结束时间 * @return int 返回间隔天数 */ public static int getIntervalDays(java.sql.Date startDate, java.sql.Date endDate) { long startdate = startDate.getTime(); long enddate = endDate.getTime(); long interval = enddate - startdate; int intervalday = (int) (interval / (1000 * 60 * 60 * 24)); return intervalday; }
public String validDetail(HttpServletRequest request) { Util util = new Util(); String name = request.getParameter("name"); if (name == null || name.equals("")) { return "名前を入力してください!"; } /*String hurigana=request.getParameter("hurigana"); if(hurigana==null|| hurigana.equals("")){ return "ふりがなを入力してください!"; }*/ int age = new Integer(request.getParameter("age")).intValue(); if (age <= 0) { return "年齢を入力してください!"; } Date birthDay = null; try { birthDay = convertDate(request.getParameter("birthDay")); } catch (Exception e) { e.printStackTrace(); } if (birthDay == null || birthDay.equals("")) { return "生年月日を正しく入力してください!"; } return ""; }
@Override public String getCalculatedFollowupDateForAjaxCall(String baseDate) { final String empty = ""; String[] elements = baseDate.split("/"); if (elements.length == 3) { try { int month = Integer.parseInt(elements[0]); int day = Integer.parseInt(elements[1]); int year = Integer.parseInt(elements[2]); if (year < 100) { year = year + 2000; } Date requestedDate = new Date(year, month - 1, day - 1); Date followUpDate = getCalculatedFollowupDate(requestedDate); return (followUpDate.getMonth() + 1) + "/" + (followUpDate.getDate() + 1) + "/" + followUpDate.getYear(); } catch (Exception e) { e.printStackTrace(); // something wasn't a number or a valid date element; } } return empty; }
@Override public boolean processRules(CommitteeScheduleDeadlineEvent deadlineCommitteeScheduleEvent) { boolean rulePassed = true; List<CommitteeScheduleBase> committeeSchedules = deadlineCommitteeScheduleEvent.getCommitteeSchedules(); int count = 0; for (CommitteeScheduleBase committeeSchedule : committeeSchedules) { Date deadline = committeeSchedule.getProtocolSubDeadline(); Date schedule = committeeSchedule.getScheduledDate(); if ((schedule != null) && (deadline != null) && (schedule.before(deadline))) { reportError( String.format(ID, count), KeyConstants.ERROR_COMMITTEESCHEDULE_DEADLINE, deadline.toString(), schedule.toString()); rulePassed = false; } count++; } return rulePassed; }
/* * (non-Javadoc) * * @see controleur.AbstractServlet#recupInitParameters() */ @Override protected void recupInfos(HttpServletRequest req) { idEleve = Integer.parseInt(req.getParameter("idEleve")); eleve = (IEleve) FabriquePersistance.getInstance(FabriquePersistance.ELEVE).readByID(idEleve); eleve.setNumMat(req.getParameter("numMat")); eleve.setNom(req.getParameter("nom")); eleve.setPrenom(req.getParameter("prenom")); eleve.setSexe(req.getParameter("sexe")); if (req.getParameter("boursier") == null) eleve.setBoursier("0"); else eleve.setBoursier("1"); if (req.getParameter("aero") == null) eleve.setAero("0"); else eleve.setAero("1"); eleve.setIDp("0"); eleve.setCatSociale(req.getParameter("catSociale")); eleve.setSituFamille(req.getParameter("situFamille")); eleve.setOldClasse(eleve.getClasse()); if (req.getParameter("dateNaissance") != "") eleve.setDateNaissance(Date.valueOf(req.getParameter("dateNaissance"))); if (req.getParameter("dateArrivee") != "") eleve.setDateArrivee(Date.valueOf(req.getParameter("dateArrivee"))); if (req.getParameter("nouveau") == null) eleve.setNouveau("0"); else eleve.setNouveau("1"); eleve.setAnneeEntree(Integer.parseInt(req.getParameter("anneeEntree"))); if (req.getParameter("rdc") != "") eleve.setRdc(Date.valueOf(req.getParameter("rdc"))); eleve.setClasse( (IClasse) FabriquePersistance.getInstance(FabriquePersistance.CLASSE) .readByID(Integer.parseInt(req.getParameter("idClasse")))); }
@Test public void testErreurDateNull() { final DateMinMaxValidator test = new DateMinMaxValidator(Date.valueOf("2012-01-10"), Date.valueOf("2012-08-18")); test.check((String) null); assertFalse(test.hasError()); }
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ProjectDao projectDao = (ProjectDao) this.getServletContext().getAttribute("projectDao"); try { // request.setCharacterEncoding("UTF-8"); // CharSetFilter에서 처리 Member member = (Member) request.getSession().getAttribute("member"); Project project = new Project() .setTitle(request.getParameter("title")) .setContent(request.getParameter("content")) .setStartDate(Date.valueOf(request.getParameter("startDate"))) .setEndDate(Date.valueOf(request.getParameter("endDate"))) .setTag(request.getParameter("tag")) .setLeader(member.getEmail()); projectDao.add(project); response.sendRedirect("list"); } catch (Exception e) { e.printStackTrace(); RequestDispatcher rd = request.getRequestDispatcher("/error.jsp"); rd.forward(request, response); } }
@Test public void testGetDate() throws Exception { List<Query.Type> types = Arrays.asList(Query.Type.DATE); for (Query.Type type : types) { try (Cursor cursor = new SimpleCursor( QueryResult.newBuilder() .addFields(Field.newBuilder().setName("col1").setType(type).build()) .addFields(Field.newBuilder().setName("null").setType(type).build()) .addRows( Query.Row.newBuilder() .addLengths("2008-01-02".length()) .addLengths(-1) // SQL NULL .setValues(ByteString.copyFromUtf8("2008-01-02"))) .build())) { Row row = cursor.next(); Assert.assertNotNull(row); Assert.assertEquals(Date.valueOf("2008-01-02"), row.getObject("col1")); Assert.assertEquals(Date.valueOf("2008-01-02"), row.getDate("col1")); Assert.assertEquals(new Date(1199232000000L), row.getDate("col1", GMT)); Assert.assertFalse(row.wasNull()); Assert.assertEquals(null, row.getDate("null")); Assert.assertTrue(row.wasNull()); } } }
public static int calculate(Date awal, Date akhir) { Long millis1 = awal.getTime(); Long millis2 = akhir.getTime(); Long hasil = (millis2 - millis1) / DAY_IN_MILIS; return hasil.intValue(); }
public static void main(String[] args) { try { String OM_DBConnectionString = getDBPath(); SalesInfo.setConnectionString(OM_DBConnectionString); Properties defaultProps = new Properties(); FileInputStream in = new FileInputStream("app.properties"); defaultProps.load(in); in.close(); String config = defaultProps.getProperty("environment"); String excludes = "exclude" + config; String excludeFile = defaultProps.getProperty(excludes); String appEagleProducts = "aeProducts" + config; String appEagleProductsFile = defaultProps.getProperty(appEagleProducts); Calendar calendar = Calendar.getInstance(); java.util.Date currentDate = calendar.getTime(); java.sql.Date date = new java.sql.Date(currentDate.getTime()); String outputFile = "uploadAppEagle" + date.toString() + ".csv"; ; generateAppEagleFile(appEagleProductsFile, excludeFile, outputFile); } catch (Exception ex) { out.println(ex.getMessage() + " in main"); } }
public void initialise(RandomiserInstance ri) { LinkedHashMap hashmap; String sMax, sFromDate, sDateTo, sPercent, sNull, sSelectedDays; int iMax; Object objValues[] = new Object[3]; txtName.setText(ri.getName()); txtDescription.setText(ri.getDescription()); hashmap = ri.getProperties(); sMax = (String) hashmap.get("rangesNum"); try { iMax = Integer.parseInt(sMax); for (int i = 0; i < iMax; i++) { sFromDate = (String) hashmap.get("fromField" + i); objValues[0] = Date.valueOf(sFromDate); sDateTo = (String) hashmap.get("toField" + i); objValues[1] = Date.valueOf(sDateTo); sPercent = (String) hashmap.get("percentField" + i); objValues[2] = Integer.valueOf(sPercent); newModelDates.addRow(objValues); } sNull = (String) hashmap.get("nullField"); spinNull.setValue(Integer.parseInt(sNull)); } catch (Exception e) { logger.warn("Error while setting properties:", e); } sSelectedDays = (String) hashmap.get("selectedDays"); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; CmsArticleEntity that = (CmsArticleEntity) o; if (id != that.id) return false; if (articleClassId != null ? !articleClassId.equals(that.articleClassId) : that.articleClassId != null) return false; if (articleState != null ? !articleState.equals(that.articleState) : that.articleState != null) return false; if (content != null ? !content.equals(that.content) : that.content != null) return false; if (createTime != null ? !createTime.equals(that.createTime) : that.createTime != null) return false; if (createUserId != null ? !createUserId.equals(that.createUserId) : that.createUserId != null) return false; if (hits != null ? !hits.equals(that.hits) : that.hits != null) return false; if (summary != null ? !summary.equals(that.summary) : that.summary != null) return false; if (title != null ? !title.equals(that.title) : that.title != null) return false; if (updateTime != null ? !updateTime.equals(that.updateTime) : that.updateTime != null) return false; if (updateUserId != null ? !updateUserId.equals(that.updateUserId) : that.updateUserId != null) return false; return true; }
// Author - Shalin Banjara // Usage - Business logic to calculate the available timeslots for a particular department based // on capacity and day of week. public List<DepartmentTimeslotLinkage> timeslotByDepartment(Utility u) throws BadSqlGrammarException { List<DepartmentTimeslotLinkage> departmenttimeslots = new ArrayList<DepartmentTimeslotLinkage>(); List<DepartmentTimeslotLinkage> finalDepartmenttimeslots = new ArrayList<DepartmentTimeslotLinkage>(); departmenttimeslots = departmentTimeslotMapper.getTimeslotByDepartment(u); int i = 0; if (departmenttimeslots.size() > 0) { for (int j = 0; j < departmenttimeslots.size(); j++) { DepartmentTimeslotLinkage depTime = departmenttimeslots.get(j); Date d = Date.valueOf(u.getAppointmentDate()); depTime.setAppointmentDate(d); // System.out.println(d.getDay()); String s = depTime.getWeekdays().substring(d.getDay()); if (s.startsWith("1")) { finalDepartmenttimeslots.add(depTime); System.out.println(depTime.toString()); } } } return finalDepartmenttimeslots; }
/** * choose related screening plans for an activity * * @return String * @throws */ public String choosePlan() { List<Integer> ids = getPlanIds(screeningPlanId); Activity activityWanted = new Activity(); activityWanted.setFilmId(filmId); activityWanted.setName(activityName); activityWanted.setQuestion1(question); activityWanted.setOptions1(answer1); activityWanted.setOptions2(answer2); activityWanted.setOptions3(answer3); LOGGER.info("integral: " + integral); activityWanted.setIntegral(integral); activityWanted.setFilmName(filmName); activityWanted.setOver(0); activityWanted.setScreeningPlanId(screeningPlanId); LOGGER.info("screening plans selected id: " + screeningPlanId); Date startDate = DateUtil.getCurrentDate(); Date endDate = DateUtil.getCurrentDate(); for (Integer id : ids) { ScreeningPlan screeningPlan = screeningPlanService.getPlanById(id); Date planStart = screeningPlan.getStartDate(); Date planEnd = screeningPlan.getEndDate(); startDate = startDate.before(planStart) ? planStart : startDate; endDate = endDate.before(planEnd) ? planEnd : endDate; } activityWanted.setStartDate(startDate); activityWanted.setEndDate(endDate); LOGGER.info("activity to insert: " + activityWanted.toString()); waiterService.makeActivity(activityWanted); return SUCCESS; }
public void testCurrentDate() throws Exception { String selectSql = "SELECT current_date() FROM " + FULL_TABLE_NAME; try (Connection conn = DriverManager.getConnection(getUrl())) { conn.setAutoCommit(false); ResultSet rs = conn.createStatement().executeQuery(selectSql); assertFalse(rs.next()); String upsert = "UPSERT INTO " + FULL_TABLE_NAME + "(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk) VALUES(?, ?, ?, ?, ?, ?)"; PreparedStatement stmt = conn.prepareStatement(upsert); // upsert two rows TestUtil.setRowKeyColumns(stmt, 1); stmt.execute(); conn.commit(); rs = conn.createStatement().executeQuery(selectSql); assertTrue(rs.next()); Date date1 = rs.getDate(1); assertFalse(rs.next()); Thread.sleep(1000); rs = conn.createStatement().executeQuery(selectSql); assertTrue(rs.next()); Date date2 = rs.getDate(1); assertFalse(rs.next()); assertTrue( "current_date() should change while executing multiple statements", date2.getTime() > date1.getTime()); } }
@Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { if (!children.get(0).evaluate(tuple, ptr)) { return false; } String timezone = Bytes.toString(ptr.get(), ptr.getOffset(), ptr.getLength()); if (!children.get(1).evaluate(tuple, ptr)) { return false; } if (!cachedTimeZones.containsKey(timezone)) { TimeZone tz = TimeZone.getTimeZone(timezone); if (!tz.getID().equals(timezone)) { throw new IllegalDataException("Invalid timezone " + timezone); } cachedTimeZones.put(timezone, tz); } Date date = (Date) PDate.INSTANCE.toObject(ptr, children.get(1).getSortOrder()); int offset = cachedTimeZones.get(timezone).getOffset(date.getTime()); ptr.set(PInteger.INSTANCE.toBytes(offset / MILLIS_TO_MINUTES)); return true; }
/** * Trasforma la data in una stringa * * @param data - Data * @return Stringa contenente la data corrente nel seguente formato "5 maggio 2012" */ @SuppressWarnings("deprecation") public String parse(Date data) { int gg = data.getDate(); int mm = data.getMonth(); int aa = data.getYear(); return (gg + " " + month[mm] + " " + aa); }
@BeforeClass public void setUp() { MockitoAnnotations.initMocks(this); acdc = new Musician(); acdc.setRealName("Brian Johnson"); acdc.setArtistName("AC/DC"); acdc.setDateOfBirth(Date.valueOf("1945-10-15")); backInBlackAlbum = new Album(); backInBlackAlbum.setMusician(acdc); backInBlackAlbum.setReleaseDate(Date.valueOf("1980-7-25")); backInBlackAlbum.setTitle("Back In Black"); shootToThrillSong = new Song(); shootToThrillSong.setTitle("Shoot To Thrill"); shootToThrillSong.setAlbum(backInBlackAlbum); shootToThrillSong.setGenre(progressiveRock); shootToThrillSong.setMusician(acdc); shootToThrillSong.setAlbumPosition(2); shootToThrillSong.setBitrate(320); albumDTO = new AlbumDTO(); albumDTO.setTitle(backInBlackAlbum.getTitle()); albumDTO.setReleaseDate(backInBlackAlbum.getReleaseDate()); albumDTO.setMusician(new MusicianDTO()); albumDTO.setCover(backInBlackAlbum.getCover()); progressiveRock = new Genre(); progressiveRock.setTitle("Progressive Rock"); progressiveRock.setYearOfOrigin(1960); }
@Test public void testCalendar2SqlDate() { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(time); Date date = sqlDateConverter.convert(calendar); assertEquals(time, date.getTime()); }
@Override protected LocalDate doNormalize(Object value, DbAttribute targetAttribute) { switch (value.getClass().getName()) { case "java.util.Date": { Date date = (Date) value; return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); } case "java.sql.Date": { java.sql.Date date = (java.sql.Date) value; return date.toLocalDate(); } case "java.sql.Time": { throw new LmRuntimeException( "Will not perform lossy conversion from " + getTypeName() + ": " + value); } case "java.sql.Timestamp": { Timestamp timestamp = (Timestamp) value; return timestamp.toLocalDateTime().toLocalDate(); } default: { throw new LmRuntimeException( "Value can not be mapped to " + getTypeName() + ": " + value); } } }
private String generateTestDataFileForPartitionInput() throws Exception { final File file = getTempFile(); PrintWriter printWriter = new PrintWriter(file); String partValues[] = {"1", "2", "null"}; for (int c = 0; c < partValues.length; c++) { for (int d = 0; d < partValues.length; d++) { for (int e = 0; e < partValues.length; e++) { for (int i = 1; i <= 5; i++) { Date date = new Date(System.currentTimeMillis()); Timestamp ts = new Timestamp(System.currentTimeMillis()); printWriter.printf( "%s,%s,%s,%s,%s", date.toString(), ts.toString(), partValues[c], partValues[d], partValues[e]); printWriter.println(); } } } } printWriter.close(); return file.getPath(); }
public Object set(Object o, Date value) { if (value == null) { return null; } ((Date) o).setTime(value.getTime()); return o; }
@RequestMapping("update.do") public void update(Scanner keyScan) { try { System.out.print("변경할 프로젝트 번호?"); int no = Integer.parseInt(keyScan.nextLine()); Project oldProject = projectDao.selectOne(no); Project project = new Project(); System.out.printf("프로젝트명(%s)? ", oldProject.getTitle()); project.setTitle(keyScan.nextLine()); System.out.printf("시작일(%s)? ", oldProject.getStartDate()); project.setStartDate(Date.valueOf(keyScan.nextLine())); System.out.printf("종료일(%s)? ", oldProject.getEndDate()); project.setEndDate(Date.valueOf(keyScan.nextLine())); System.out.printf("설명(%s)? ", oldProject.getDescription()); project.setDescription(keyScan.nextLine()); if (CommandUtil.confirm(keyScan, "변경하시겠습니까?")) { projectDao.update(no, project); System.out.println("변경하였습니다."); } else { System.out.println("변경을 취소하였습니다."); } } catch (IndexOutOfBoundsException e) { System.out.println("유효한 번호가 아닙니다."); } catch (Exception e) { System.out.println("데이터 로딩에 실패했습니다."); } }
@Test public void findCustomerWithCar() { assertTrue(car1.getAvailable()); assertTrue(car2.getAvailable()); assertTrue(car3.getAvailable()); manager.rentCarToCustomer( car1, customer1, Date.valueOf("2012-03-21"), Date.valueOf("2012-03-31")); assertEquals(customer1, manager.findCustomerWithCar(car1)); assertCustomerDeepEquals(customer1, manager.findCustomerWithCar(car1)); assertTrue(car2.getAvailable()); assertTrue(car3.getAvailable()); try { manager.findCustomerWithCar(null); fail(); } catch (IllegalArgumentException e) { } try { manager.findCustomerWithCar(carWithoutID); fail(); } catch (IllegalArgumentException e) { } }
/** * This method is to save alert * * @param formBase * @param result * @param request * @param response * @return ModelAndView */ @RequestMapping(params = "methodToCall=saveAlert") public ModelAndView saveAlert( @ModelAttribute("KualiForm") DocumentFormBase formBase, BindingResult result, HttpServletRequest request, HttpServletResponse response) { MaintenanceDocumentForm maintenanceDocumentForm = (MaintenanceDocumentForm) formBase; OlePersistableBusinessObjectBase olePersistableBusinessObjectBase = (OlePersistableBusinessObjectBase) maintenanceDocumentForm.getDocument().getNewMaintainableObject().getDataObject(); int index = Integer.parseInt( maintenanceDocumentForm.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX)); olePersistableBusinessObjectBase.getAlertBoList().get(index).setEditFlag(false); AlertBo alertBo = olePersistableBusinessObjectBase.getAlertBoList().get(index); String status = null; if (alertBo.getAlertDate() != null) { Date alertDate = alertBo.getAlertDate(); if (alertDate.toString().equals(new Date(System.currentTimeMillis()).toString())) { status = "Active"; } else { int dateCompare = alertBo.getAlertDate().compareTo(new Date(System.currentTimeMillis())); if (dateCompare > 0) { status = "Future"; } else if (dateCompare < 0) { status = "Complete"; } } } alertBo.setStatus(status); return super.navigate(maintenanceDocumentForm, result, request, response); }