List of usage examples for java.sql Date toString
@SuppressWarnings("deprecation") public String toString()
From source file:org.kuali.coeus.common.committee.impl.rules.CommitteeScheduleDateConflictRule.java
/** * This method process date conflict for soft error message. * @param addCommitteeScheduleEvent/*from www . j a v a2 s. c om*/ * @return */ private boolean processSoftErrors(CommitteeScheduleDateConflictEvent addCommitteeScheduleEvent) { boolean rulePassed = true; List<Date> datesInConflict = addCommitteeScheduleEvent.getScheduleData().getDatesInConflict(); for (Date date : datesInConflict) { reportSoftError(DATES_IN_CONFLICT_ERROR_KEY, KeyConstants.ERROR_COMMITTEESCHEDULE_DATES_SKIPPED, date.toString()); } return rulePassed; }
From source file:com.strider.datadefender.extensions.BiographicFunctions.java
/** * Generates random 9-digit social insurance number * @return String/*from ww w . j ava 2 s. c o m*/ * @throws java.text.ParseException */ public java.sql.Date randomBirthDate() throws java.text.ParseException { final GregorianCalendar gc = new GregorianCalendar(); final int year = randBetween(1900, 2016); gc.set(GregorianCalendar.YEAR, year); final int dayOfYear = randBetween(1, gc.getActualMaximum(GregorianCalendar.DAY_OF_YEAR)); gc.set(GregorianCalendar.DAY_OF_YEAR, dayOfYear); final String birthDate = prependZero(gc.get(GregorianCalendar.DAY_OF_MONTH)) + "-" + prependZero(gc.get(GregorianCalendar.MONTH) + 1) + "-" + gc.get(GregorianCalendar.YEAR); log.debug("BirthDate:[" + birthDate + "]"); final DateFormat format = new SimpleDateFormat("dd-MM-yyyy", Locale.US); final java.sql.Date date = new java.sql.Date(format.parse(birthDate).getTime()); log.debug("Generated BirthDate:[" + date.toString() + "]"); return date; }
From source file:com.livgrhm.kansas.api.AuthMap.java
public boolean isAuthorised(String hash, String ip) { System.out.println("AUTHORISING: " + hash + " IP: " + ip); if (hash == null || hash.equals("")) { return false; }//from w w w .j a va 2 s . co m this.thisAuth = (AuthItem) this.authMap.get(hash); // current expiration time set as 8 hours DateUtils du = new DateUtils(); java.sql.Date testDate = new java.sql.Date((new java.util.Date()).getTime()); if (this.thisAuth != null) { if (!this.thisAuth.loginDate.toString().equals(testDate.toString()) || !this.thisAuth.ipAddress.equals(ip)) { // session expired - so return false, and delete this entry authMap.remove(hash); return false; } return true; // i.e. the hash exists, and is current! } // hash is not in the list, but could be in the database (i.e. logged on from another instance of the server, or server could have // been bounced. So see if it is in the db User user = this.dao.getUserByCurrentHash(hash); if (user == null) { return false; // hash doesn't exist } if (!user.getUserAuthTimestamp().toString().equals(testDate.toString())) { return false; // hash is in the db, but has expired } if (!user.getUserLastIP().equals(ip)) { return false; // hash is in the db, but wrong IP address } // so has exists and is still current - update thisAuth (i.e. for the current request), and update the hash table and return true AuthItem ai = new AuthItem(); ai.userId = user.getUserId(); ai.loginDate = user.getUserAuthTimestamp(); ai.ipAddress = ip; authMap.put(hash, ai); thisAuth = ai; return true; }
From source file:org.kuali.kfs.module.endow.document.validation.impl.TicklerRule.java
/** * Checks Tickler's Frequency Or Next Due Date presence and validity. *///from w ww. java 2 s .c om private void checkFrequencyOrNextDueDateRequirement() { //Check whether frequency and next due date are both missing. if ((StringUtils.isEmpty(getNewTickler().getFrequencyCode()) && getNewTickler().getNextDueDate() == null)) { putGlobalError(EndowKeyConstants.TicklerConstants.ERROR_TICKLER_FREQUENCYORNEXTDUEDATEREQUIREMENT); } //Check whether frequency and next due date are both present. If yes, then check if the date matches up with frequency next due date. if (!StringUtils.isEmpty(getNewTickler().getFrequencyCode()) && getNewTickler().getNextDueDate() != null) { FrequencyCodeServiceImpl frequencyCodeServiceImpl = (FrequencyCodeServiceImpl) SpringContext .getBean(FrequencyCodeServiceImpl.class); Date date = frequencyCodeServiceImpl.calculateProcessDate(getNewTickler().getFrequencyCode()); if (date.toString().compareTo((getNewTickler().getNextDueDate().toString())) != 0) { putGlobalError(EndowKeyConstants.TicklerConstants.ERROR_TICKLER_FREQUENCY_NEXTDUEDATE_MISMATCH); } } }
From source file:view.ViewRequestedFileStatus.java
private void loadFileRequestDetails() { Dbcon dbcon = new Dbcon(); DefaultTableModel dt = (DefaultTableModel) requested_files_table.getModel(); ResultSet rs = dbcon.select(//from w ww. j a v a2s . com "SELECT hp.name , s.request_id,s.requested_date,s.status, th.attr_1,h.name, th.encrypted_file_path , s.encryption_id as eid FROM tbl_file_request s INNER JOIN tbl_data_member hp on hp.data_member_id = s.file_owner_data_member INNER JOIN tbl_organisation h on hp.organization_id = h.organisation_id INNER JOIN tbl_file_encryption_logs th on hp.organization_id = h.organisation_id where requested_data_member='" + DataMemberLogin.logged_in_user_id + "' and th.encryption_id=s.encryption_id"); try { while (rs.next()) { String date1 = rs.getString(3); long date2 = Long.parseLong(date1); Date date3 = new Date(date2); String date = date3.toString(); String status_string = rs.getString(4); int status_int = Integer.parseInt(status_string); String status; if (status_int == 2) { status = "pending"; } else if (status_int == 1) { status = "approved"; } else { status = "rejected"; } dt.addRow(new String[] { rs.getString(2), rs.getString(5), rs.getString(1), rs.getString(6), date, status, rs.getString("encrypted_file_path"), rs.getString("eid") }); } requested_files_table.setModel(dt); } catch (SQLException ex) { ex.printStackTrace(); } }
From source file:org.apache.hive.storage.jdbc.spitter.DateIntervalSplitter.java
@Override public List<MutablePair<String, String>> getIntervals(String lowerBound, String upperBound, int numPartitions, TypeInfo typeInfo) {/*from w w w. j a v a2s. c o m*/ List<MutablePair<String, String>> intervals = new ArrayList<>(); Date dateLower = Date.valueOf(lowerBound); Date dateUpper = Date.valueOf(upperBound); double dateInterval = (dateUpper.getTime() - dateLower.getTime()) / (double) numPartitions; Date splitDateLower, splitDateUpper; for (int i = 0; i < numPartitions; i++) { splitDateLower = new Date(Math.round(dateLower.getTime() + dateInterval * i)); splitDateUpper = new Date(Math.round(dateLower.getTime() + dateInterval * (i + 1))); if (splitDateLower.compareTo(splitDateUpper) < 0) { intervals .add(new MutablePair<String, String>(splitDateLower.toString(), splitDateUpper.toString())); } } return intervals; }
From source file:com.splicemachine.db.iapi.types.SQLDateTest.java
@Test public void serdeValueData() throws Exception { UnsafeRow row = new UnsafeRow(1); UnsafeRowWriter writer = new UnsafeRowWriter(new BufferHolder(row), 1); Date date = new Date(System.currentTimeMillis()); int computeEncodedDate = SQLDate.computeEncodedDate(date); SQLDate value = new SQLDate(date); SQLDate valueA = new SQLDate(); value.write(writer, 0);//from ww w . j a va2s .c o m Assert.assertEquals("SerdeIncorrect", computeEncodedDate, row.getInt(0)); valueA.read(row, 0); Assert.assertEquals("SerdeIncorrect", date.toString(), valueA.getDate(new GregorianCalendar()).toString()); }
From source file:org.kuali.kfs.module.purap.util.ElectronicInvoiceParserTest.java
private void validateInvoiceDetailRequestHeader() { String invoiceDate = eInvoice.getInvoiceDetailRequestHeader().getInvoiceDateString(); Date date = ElectronicInvoiceUtils.getDate(invoiceDate); assertEquals(ElectronicInvoiceParserFixture.invoiceDate, invoiceDate); assertEquals(date.toString(), eInvoice.getInvoiceDetailRequestHeader().getInvoiceDate().toString()); assertEquals(ElectronicInvoiceParserFixture.invoiceID, eInvoice.getInvoiceDetailRequestHeader().getInvoiceId()); assertEquals(ElectronicInvoiceParserFixture.operation, eInvoice.getInvoiceDetailRequestHeader().getOperation()); assertEquals(ElectronicInvoiceParserFixture.purpose, eInvoice.getInvoiceDetailRequestHeader().getPurpose()); assertTrue(eInvoice.getInvoiceDetailRequestHeader().isInformationOnly()); assertTrue(eInvoice.getInvoiceDetailRequestHeader().isHeaderInvoiceIndicator()); assertTrue(eInvoice.getInvoiceDetailRequestHeader().isTaxInLine()); assertTrue(eInvoice.getInvoiceDetailRequestHeader().isSpecialHandlingInLine()); assertTrue(eInvoice.getInvoiceDetailRequestHeader().isShippingInLine()); assertTrue(eInvoice.getInvoiceDetailRequestHeader().isDiscountInLine()); validateInvoicePartners();/* w w w . j a va 2 s.com*/ validateShippingDetail(); validatePaymentTermElement(); }
From source file:org.apache.drill.exec.store.hive.HiveTestDataGenerator.java
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(); }//from w w w . ja va2 s .co m } } } printWriter.close(); return file.getPath(); }
From source file:org.kuali.kra.committee.rules.CommitteeScheduleDateConflictRule.java
/** * Helper method to identify potential conflicts and adds error message to map. * @param committeeSchedules/*from www . j a v a 2s . c o m*/ * @param conflictDates */ private void identifyPotentialConflicts(List<CommitteeSchedule> committeeSchedules, List<Date> conflictDates) { Date scheduleDate = null; int count = 0; for (Date date : conflictDates) { count = 0; for (CommitteeSchedule committeeSchedule : committeeSchedules) { scheduleDate = committeeSchedule.getScheduledDate(); if (DateUtils.isSameDay(date, scheduleDate)) { reportError(String.format(ID, count), KeyConstants.ERROR_COMMITTEESCHEDULE_DATE_CONFLICT, scheduleDate.toString()); } count++; } } }