private Set<Contributor> theContributors() { try { Set<Contributor> contributors = new HashSet<Contributor>(3); Contributor contributor = new Contributor(); contributor.setId("ff808081369cf58901369cf88a3d0003"); contributor.setUserId(1); contributor.setLastVisit(null); contributor.setLastValidation(null); contributors.add(contributor); contributor = new Contributor(); contributor.setId("f808081369cf58901369cf88a3d0004"); contributor.setUserId(2); contributor.setLastVisit(Timestamp.valueOf("2012-04-10 17:57:08.8")); contributor.setLastValidation(Timestamp.valueOf("2012-04-10 17:57:08.818")); contributors.add(contributor); contributor = new Contributor(); contributor.setId("ff808081369cf58901369cf88a3d0005"); contributor.setUserId(0); contributor.setLastVisit(Timestamp.valueOf("2012-04-10 17:56:46.549")); contributor.setLastValidation(Timestamp.valueOf("2012-04-10 17:56:46.574")); contributors.add(contributor); return contributors; } catch (Exception ex) { throw new RuntimeException(ex); } }
@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); } } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; AgencyUser that = (AgencyUser) o; if (userId != that.userId) return false; if (travelAgencyId != that.travelAgencyId) return false; if (createdBy != that.createdBy) return false; if (jpaVersionNumber != that.jpaVersionNumber) return false; if (isActiveUserFlag != null ? !isActiveUserFlag.equals(that.isActiveUserFlag) : that.isActiveUserFlag != null) return false; if (createDate != null ? !createDate.equals(that.createDate) : that.createDate != null) return false; if (lastUpdateDate != null ? !lastUpdateDate.equals(that.lastUpdateDate) : that.lastUpdateDate != null) return false; if (lastUpdatedBy != null ? !lastUpdatedBy.equals(that.lastUpdatedBy) : that.lastUpdatedBy != null) return false; return true; }
public static Date getLastCalendarModifiedDate(long calendarId) throws PortalException, SystemException { ClassLoader classLoader = ClassLoaderPool.getClassLoader("calendar-portlet"); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(CalendarBooking.class, classLoader); dynamicQuery.add(RestrictionsFactoryUtil.eq("calendarId", calendarId)); dynamicQuery.setProjection(ProjectionFactoryUtil.property("modifiedDate")); dynamicQuery.setLimit(0, 1); dynamicQuery.addOrder(OrderFactoryUtil.desc("modifiedDate")); List<Object> lastModifiedDate = CalendarBookingLocalServiceUtil.dynamicQuery(dynamicQuery); if ((lastModifiedDate != null) && !lastModifiedDate.isEmpty()) { Timestamp ts = (Timestamp) lastModifiedDate.get(0); return new Date(ts.getTime()); } return new Date(); }
public static java.util.Date addMonths(Comparable<?> param1, Comparable<?> param2, Calendar cal) throws ParseException { if (param1 == null && param2 == null) { return null; } try { int months = getInteger(param2); if (param1 instanceof Timestamp) { Timestamp d = (Timestamp) param1; cal.setTimeInMillis(d.getTime()); cal.add(Calendar.MONTH, months); return new Timestamp(cal.getTimeInMillis()); } else if (param1 instanceof java.sql.Date) { java.util.Date d = (java.util.Date) param1; cal.setTimeInMillis(d.getTime()); cal.add(Calendar.MONTH, months); return new java.util.Date(cal.getTimeInMillis()); } else { throw new ParseException(); } } catch (ParseException e) { throw new ParseException( WRONG_TYPE + " month_between(" + param1.getClass() + "," + param2.getClass() + ")"); } }
@Override public ExpiringCode generateCode(String data, Timestamp expiresAt) { cleanExpiredEntries(); if (data == null || expiresAt == null) { throw new NullPointerException(); } if (expiresAt.getTime() < System.currentTimeMillis()) { throw new IllegalArgumentException(); } int count = 0; while (count < 3) { count++; String code = generator.generate(); try { int update = jdbcTemplate.update(insert, code, expiresAt.getTime(), data); if (update == 1) { ExpiringCode expiringCode = new ExpiringCode(code, expiresAt, data); return expiringCode; } else { logger.warn("Unable to store expiring code:" + code); } } catch (DataIntegrityViolationException x) { if (count == 3) { throw x; } } } return null; }
/** * Deactivates a given persistent ID. * * @param persistentId ID to deactivate * @param deactivation deactivation time, if null the current time is used * @throws java.sql.SQLException thrown if there is a problem communication with the database */ public void deactivatePersistentId(String persistentId, Timestamp deactivation) throws SQLException { Timestamp deactivationTime = deactivation; if (deactivationTime == null) { deactivationTime = new Timestamp(System.currentTimeMillis()); } Connection dbConn = dataSource.getConnection(); try { log.debug( "Deactivating persistent id {} as of {}", persistentId, deactivationTime.toString()); PreparedStatement statement = dbConn.prepareStatement(deactivateIdSQL); statement.setQueryTimeout(queryTimeout); statement.setTimestamp(1, deactivationTime); statement.setString(2, persistentId); statement.executeUpdate(); } finally { try { if (dbConn != null && !dbConn.isClosed()) { dbConn.close(); } } catch (SQLException e) { log.error("Error closing database connection", e); } } }
private String convertTupleToJsonString(Object[] tuple) { Timestamp ts = new Timestamp(((Long) tuple[0]).longValue()); tuple[0] = ts.toString(); JSONArray jsonArray = new JSONArray(); jsonArray.addAll(Arrays.asList(tuple)); return jsonArray.toString(); }
@Test public void levelUpWeekend() { LevelUpCampaign campaign = new LevelUpCampaign(100, CampaignState.ACTIVE); Timestamp executionTime = Timestamp.valueOf("2016-01-21 00:00:00"); String message = campaign.testFailCalendarRestriction(null, executionTime, true); System.out.println("Got message: " + message); assertNotNull(message); executionTime = Timestamp.valueOf("2016-01-22 00:00:00"); message = campaign.testFailCalendarRestriction(null, executionTime, true); System.out.println("Got message: " + message); assertNotNull(message); executionTime = Timestamp.valueOf("2016-01-23 00:00:00"); message = campaign.testFailCalendarRestriction(null, executionTime, true); System.out.println("Got message: " + message); assertThat(message, is((String) null)); }
static Timestamp bucketByHour(Timestamp t) { Timestamp result = new Timestamp(t.getTime()); result.setSeconds(0); result.setMinutes(0); result.setNanos(0); return result; }
private static void printTimeSeries( String filename, String title, MergeMap.MinMap<String, Timestamp> firstUse) throws FileNotFoundException { PrintWriter out = new PrintWriter(filename); out.println(title + ",time,full time"); TreeSet<TimeSeries<String, Timestamp>> series = new TreeSet<TimeSeries<String, Timestamp>>(); for (Map.Entry<String, Timestamp> e : firstUse.entrySet()) { series.add(new TimeSeries<String, Timestamp>(e.getKey(), e.getValue())); } Multiset<Timestamp> counter = new Multiset<Timestamp>(new TreeMap<Timestamp, Integer>()); for (TimeSeries<String, Timestamp> t : series) { counter.add(bucketByHour(t.v)); } int total = 0; SimpleDateFormat format = new SimpleDateFormat("h a EEE"); SimpleDateFormat defaultFormat = new SimpleDateFormat(); for (Map.Entry<Timestamp, Integer> e : counter.entrySet()) { Timestamp time = e.getKey(); total += e.getValue(); if (time.after(fixitStart)) out.printf("%d,%s,%s%n", total, format.format(time), defaultFormat.format(time)); } out.close(); }
/** * Erstellt eine neue Buchung * * @param roomTag: der Raumtyp als String * @param location: der Standort als String * @param bookedFrom: das Startdatum als String * @param bookedTil: das Enddatum als String * @param user: die Id des Nutzers als int */ public void newBooking( final String bookedFrom, final String bookedTil, final int user, final String location, final String roomTag, final List<String> material_zur_buchung) { String transF[] = bookedFrom.split("T", 2); String bookF = transF[0] + " " + transF[1] + ":00"; Timestamp dateFrom = Timestamp.valueOf(bookF); String transT[] = bookedTil.split("T", 2); String bookT = transT[0] + " " + transT[1] + ":00"; Timestamp dateTo = Timestamp.valueOf(bookT); Standort standort = this.standRepo.getStandort(location); Room room = this.roomRepo.getRoom(roomTag, location); User userObj = this.userRepository.getUserById(user); bookingRepository.newBooking(dateFrom, dateTo, userObj, standort, room, null, null); }
public static Date getDateFromDB(String strDbName) { Session session = null; Transaction tx = null; Date rightNow = null; try { session = getSessionDude(strDbName); tx = session.beginTransaction(); Query query = session.createSQLQuery("SELECT SYSDATE FROM Dual"); List listQuery = query.list(); if (listQuery != null && !listQuery.isEmpty()) { for (int i = 0; i < listQuery.size(); i++) { java.sql.Timestamp rightNowTimeStamp = (java.sql.Timestamp) listQuery.get(i); rightNow = new Date(rightNowTimeStamp.getTime()); if (rightNow != null) { break; } } } } catch (Exception xcp) { xcp.printStackTrace(); } finally { if (session != null && session.isOpen()) { session.close(); } } return rightNow; }
@Override public Timestamp toNonNullValue(Instant value) { final Timestamp timestamp = new Timestamp(value.toEpochMilli()); timestamp.setNanos(value.getNano()); return timestamp; }
/** * ************************************************************** * * <p>Test should be exactly n calender days before reference * * @param test - the date to test * @param reference - reference date * @param days - how many days * @return - is it on that day */ public static boolean daysBefore(Timestamp test, Timestamp reference, int days) { reference = getDay(new Timestamp(reference.getTime() - 24 * 3600 * 1000 * days)); test = getDay(test); return test.equals(reference); }
public static ArrayList<Entry> getUnsyncEntries(int pid, String username, User user) throws JSONException { ArrayList<Entry> entries = new ArrayList<Entry>(); final String PREF_NAME = "u: " + username + " " + pid; Preferences prefs = Preferences.userNodeForPackage(Synchronisatie.class); String json = prefs.get(PREF_NAME, "Geen entries"); JSONObject project = new JSONObject(json); JSONArray entryArray = project.optJSONArray("entries"); for (int i = 0; i < entryArray.length(); i++) { JSONObject entryJson = entryArray.getJSONObject(i); String desc = entryJson.getString("notities"); String begin = entryJson.getString("begin"); String eind = entryJson.getString("eind"); System.out.println(eind); Date start = Timestamp.valueOf(begin); Date end; if (eind.equals("0000-00-00 00:00:00")) { end = null; } else { end = Timestamp.valueOf(eind); } Entry entry = new Entry(start, end, desc, user, pid); entry.entryid = "-1"; entries.add(entry); } return entries; }
@Test @WithMockUser(roles = "Tutor") public void currentMonthBalanceMultipleAppointments() throws Exception { Appointment testAppointment1 = new Appointment(); Appointment testAppointment2 = new Appointment(); LocalDateTime dateTime = LocalDateTime.now(); testAppointment1.setAvailability(Availability.ARRANGED); testAppointment1.setTutor(TestUtility.testUser); testAppointment1.setStudent(TestUtility.testUserTwo); testAppointment1.setWage(BigDecimal.TEN); testAppointment1.setDay(dateTime.getDayOfWeek()); testAppointment1.setTimestamp(Timestamp.valueOf(dateTime)); appointmentDao.save(testAppointment1); testAppointment2.setAvailability(Availability.ARRANGED); testAppointment2.setTutor(TestUtility.testUser); testAppointment2.setStudent(TestUtility.testUserTwo); testAppointment2.setWage(BigDecimal.TEN); testAppointment2.setDay(dateTime.getDayOfWeek()); testAppointment2.setTimestamp(Timestamp.valueOf(dateTime.minusHours(1))); appointmentDao.save(testAppointment2); BigDecimal reference = BigDecimal.TEN.multiply(ConstantVariables.PERCENTAGE); reference = reference.add(BigDecimal.TEN.multiply(ConstantVariables.PERCENTAGE)); mockMvc .perform(get("/bill").principal(this.authUser)) .andExpect(model().attribute("balance", reference.setScale(2))); }
/** * Get all archived Customers * * @return a list of all archived customers */ public ArrayList<Customer> getArchivedCustomers() { String sql = "SELECT * From arc_customer"; try { Statement statement = (Statement) connection.createStatement(); ResultSet rs = statement.executeQuery(sql); ArrayList<Customer> list = new ArrayList<>(); while (rs.next()) { int id = rs.getInt("cid"); String firstname = rs.getString("firstName"); String lastname = rs.getString("lastName"); String email = rs.getString("email"); Timestamp time = rs.getTimestamp("updatedAt"); String updatedAt = "null"; if (time != null) updatedAt = time.toString(); int discount = rs.getInt("discount"); Customer customer = new Customer(firstname, lastname, email, updatedAt, discount); // customer.setId(id); list.add(customer); } if (statement != null) statement.close(); return list; } catch (SQLException e) { e.printStackTrace(); System.out.println(e.getMessage()); return null; } }
@AroundInvoke public Object checkPermissions(InvocationContext context) throws Exception { try { logger.trace(Thread.currentThread().getName()); HivePrincipal principal = ThreadLocalVariablesKeeper.getPrincipal(); AccessKey key = principal.getKey(); if (key == null) { return context.proceed(); } if (key.getUser() == null || !key.getUser().getStatus().equals(UserStatus.ACTIVE)) { throw new HiveException(UNAUTHORIZED.getReasonPhrase(), UNAUTHORIZED.getStatusCode()); } Timestamp expirationDate = key.getExpirationDate(); if (expirationDate != null && expirationDate.before(new Timestamp(System.currentTimeMillis()))) { throw new HiveException(UNAUTHORIZED.getReasonPhrase(), UNAUTHORIZED.getStatusCode()); } Method method = context.getMethod(); AllowedKeyAction allowedActionAnnotation = method.getAnnotation(AllowedKeyAction.class); List<AllowedKeyAction.Action> actions = Arrays.asList(allowedActionAnnotation.action()); boolean isAllowed = CheckPermissionsHelper.checkAllPermissions(key, actions); if (!isAllowed) { throw new HiveException(UNAUTHORIZED.getReasonPhrase(), UNAUTHORIZED.getStatusCode()); } return context.proceed(); } finally { ThreadLocalVariablesKeeper.clean(); } }
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(); }
@AroundInvoke public Object checkArguments(InvocationContext ctx) throws Exception { try { log = Logger.getLogger(LogoutInterceptor.class); Object[] args = ctx.getParameters(); String className = ctx.getTarget().getClass().getSimpleName(); log.trace("Class name: " + className); String methodName = ctx.getMethod().getName(); log.trace("Method: " + methodName); String sessionId = (String) args[0]; if ((sessionId == null) || (sessionId.length() == 0)) { throw new Exception("sessionId should not be null"); } cf = (QueueConnectionFactory) new InitialContext().lookup(QueueNames.CONNECTION_FACTORY); queue = (Queue) new InitialContext().lookup(QueueNames.LOGOUT_QUEUE); log.trace("Queue logout: " + queue.getQueueName()); QueueConnection connection = cf.createQueueConnection(); QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); QueueSender sender = session.createSender(queue); Message logoutMessage = session.createTextMessage(sessionId); Timestamp time = new Timestamp(new Date().getTime()); // Messages will not accept timestamp property- must change to string logoutMessage.setStringProperty(PropertyNames.TIME, time.toString()); sender.send(logoutMessage); session.close(); } catch (Exception e) { log.fatal("Error in LogoutInterceptor", e); } return ctx.proceed(); }
/** Filter the event if it has already been executed. */ public ReplDBMSEvent filter(ReplDBMSEvent event) throws ReplicatorException, InterruptedException { totalEvents++; if (appliedTimes == null) appliedTimes = new TreeMap<Long, Timestamp>(); Timestamp sourceTstamp = event.getDBMSEvent().getSourceTstamp(); appliedTimes.put(event.getSeqno(), sourceTstamp); long currentTime = System.currentTimeMillis(); prefetchLatency = currentTime - sourceTstamp.getTime(); if (interval == 0 || lastChecked == 0 || (currentTime - lastChecked >= interval)) { // It is now time to check CommitSeqnoTable again checkSlavePosition(currentTime); } if (initTime == 0) initTime = sourceTstamp.getTime(); if (event.getSeqno() <= currentSeqno) { if (logger.isDebugEnabled()) logger.debug("Discarding event " + event.getSeqno() + " as it is already applied"); return null; } else while (sourceTstamp.getTime() - initTime > (aheadMaxTime * 1000)) { if (logger.isDebugEnabled()) logger.debug("Event is too far ahead of current slave position... sleeping"); // this event is too far ahead of the CommitSeqnoTable position: // sleep some time and continue long sleepStartMillis = System.currentTimeMillis(); try { prefetchState = PrefetchState.sleeping; Thread.sleep(sleepTime); } catch (InterruptedException e) { return null; } finally { prefetchState = PrefetchState.active; sleepTimeMillis += (System.currentTimeMillis() - sleepStartMillis); } // Check again CommitSeqnoTable checkSlavePosition(System.currentTimeMillis()); // and whereas the event got applied while sleeping if (event.getSeqno() <= currentSeqno) { if (logger.isDebugEnabled()) logger.debug("Discarding event " + event.getSeqno() + " as it is already applied"); return null; } } prefetchEvents++; if (logger.isDebugEnabled() && totalEvents % 20000 == 0) logger.debug( "Prefetched " + prefetchEvents + " events - Ratio " + (100 * prefetchEvents / totalEvents) + "%"); return event; }
public ModelAndView executaBrowserIphone(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); Usuario usuario = (Usuario) session.getAttribute("usuario"); if (usuario != null) { if (validaMenu.validaMenu(idMenu, usuario.getUsuarioMenu().split(","))) { List<Demandas> demandas = administracaoFacade.adiquirirDemandas(); for (Iterator<Demandas> iterator = demandas.iterator(); iterator.hasNext(); ) { Demandas demandas2 = (Demandas) iterator.next(); demandas2.setCliente(demandas2.getUsuarioSolicitante().getUsuarioNome()); demandas2.setResponsavel( demandas2.getUsuarioResponsavel() != null ? demandas2.getUsuarioResponsavel().getUsuarioNome() : ""); demandas2.setTecnicoAbriu(demandas2.getUsuarioAbriu().getUsuarioNome()); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); Timestamp time = demandas2.getDemandasDataAbertura(); demandas2.setDataAbertura(sdf.format(new Date(time.getTime()))); demandas2.setFechar("Aberta"); } session.setAttribute("demandas", demandas); return new ModelAndView("iphone/demandas_FinalizarDemanda"); } else { return new ModelAndView("index2"); } } else { return new ModelAndView("index2"); } }
private int searchCompare(Note n1, Note n2) { Integer count1 = Integer.valueOf(n1.getCount()); Integer count2 = Integer.valueOf(n2.getCount()); Date date1 = new Date((Timestamp.valueOf(n1.getDateTime())).getTime()); Date date2 = new Date((Timestamp.valueOf(n2.getDateTime())).getTime()); Integer type1 = Integer.valueOf(n1.getType()); Integer type2 = Integer.valueOf(n2.getType()); Integer imp1 = Integer.valueOf(n1.getImportant()); Integer imp2 = Integer.valueOf(n2.getImportant()); if (count1.equals(count2)) { if (n1.getType() == Note.REMINDER && n2.getType() == Note.REMINDER) { Date rdate1 = NoteComparator.StringToDate(n1.getRDateTime()); Date rdate2 = NoteComparator.StringToDate(n1.getRDateTime()); if (rdate1.equals(rdate2)) { return imp2.compareTo(imp1); } return rdate2.compareTo(rdate1); } if (type1.equals(type2)) { if (date1.equals(date2)) { return imp2.compareTo(imp1); } return date2.compareTo(date1); } return type2.compareTo(type1); } return count2.compareTo(count1); }
@Override protected void writeImpl(AionConnection con) { PacketLoggerService.getInstance().logPacketSM(this.getPacketName()); writeS(legion.getLegionName()); writeC(legion.getLegionLevel()); writeD(legion.getLegionRank()); writeH(legion.getDeputyPermission()); writeH(legion.getCenturionPermission()); writeH(legion.getLegionaryPermission()); writeH(legion.getVolunteerPermission()); writeQ(legion.getContributionPoints()); writeD(0x00); writeD(0x00); writeD(0x00); // unk 3.0 /** Get Announcements List From DB By Legion * */ Map<Timestamp, String> announcementList = legion.getAnnouncementList().descendingMap(); /** Show max 7 announcements * */ int i = 0; for (Timestamp unixTime : announcementList.keySet()) { writeS(announcementList.get(unixTime)); writeD((int) (unixTime.getTime() / 1000)); i++; if (i >= 7) { break; } } writeB(new byte[26]); // something like a spacer }
@Override public Pay mapRow(ResultSet rs, int rowNum) throws SQLException { Pay pay = new Pay(); pay.setId(rs.getInt("id")); Timestamp timestamp = rs.getTimestamp("time"); if (timestamp != null) { pay.setTime(new java.util.Date(timestamp.getTime())); } pay.setDemand_id(rs.getString("demand_id")); Manufacturer manufacturer = new Manufacturer(rs.getInt("manufacturer_id"), rs.getString("manufacturer_name"), null); pay.setManufacturer(manufacturer); User user = new User( rs.getInt("user_id"), rs.getString("user_name"), rs.getString("user_email"), rs.getString("user_login")); pay.setUser(user); pay.setStorno((rs.getInt("storno") == 0 ? false : true)); pay.setSumm(rs.getDouble("summ")); pay.setNumDoc(rs.getString("numDoc")); pay.setClient( new Client( rs.getInt("client_id"), rs.getString("client_name"), rs.getString("client_email"), rs.getString("client_address"), null)); return pay; }
private synchronized void checkTimeUpdate(long localTime, long utcTime) throws Exception { // broadcast _props.setProperty("utc", String.valueOf(utcTime)); _props.setProperty("local", String.valueOf(localTime)); TimeUpdateNotification notification = new TimeUpdateNotification(TimeUpdateNotification.UPDATE_UTC_TIME, _props); Notifier.getInstance().broadcast(notification); // wait try { wait(30000L); // 30 seconds } catch (Exception ex) { } // refreshTimeServer(); // checkSuccess(_event, _sessions[0], _sm[0], IErrorCode.NO_ERROR); long offset = utcTime - localTime; Logger.debug("Input UTC Time = " + new Timestamp(utcTime)); Logger.debug("Input Local Time = " + new Timestamp(localTime)); Logger.debug("Expected offset: " + offset); // check local to utc Timestamp ts = TimeUtil.localToUtcTimestamp(_testDate); Logger.debug("Converted local to UTc timestamp: " + ts); assertEquals("LocalToUtc conversion fail", offset, ts.getTime() - _testDate.getTime()); // check utc to local ts = TimeUtil.utcToLocalTimestamp(_testDate); Logger.debug("Converted utc to local timestamp: " + ts); assertEquals("UtcToLocal conversion fail", offset, _testDate.getTime() - ts.getTime()); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; PackingList that = (PackingList) o; if (id != null ? !id.equals(that.id) : that.id != null) return false; if (seller != null ? !seller.equals(that.seller) : that.seller != null) return false; if (buyer != null ? !buyer.equals(that.buyer) : that.buyer != null) return false; if (invoiceNo != null ? !invoiceNo.equals(that.invoiceNo) : that.invoiceNo != null) return false; if (invoiceDate != null ? !invoiceDate.equals(that.invoiceDate) : that.invoiceDate != null) return false; if (marks != null ? !marks.equals(that.marks) : that.marks != null) return false; if (descriptions != null ? !descriptions.equals(that.descriptions) : that.descriptions != null) return false; if (exportIds != null ? !exportIds.equals(that.exportIds) : that.exportIds != null) return false; if (exportNos != null ? !exportNos.equals(that.exportNos) : that.exportNos != null) return false; if (state != null ? !state.equals(that.state) : that.state != null) return false; if (createBy != null ? !createBy.equals(that.createBy) : that.createBy != null) return false; if (createDept != null ? !createDept.equals(that.createDept) : that.createDept != null) return false; if (createTime != null ? !createTime.equals(that.createTime) : that.createTime != null) return false; return true; }
public boolean update(final Article article) { Timestamp time = new Timestamp(System.currentTimeMillis()); StringBuilder sf = new StringBuilder("update "); sf.append(tableName).append(" set "); if (notEmpty(article.getTitle())) { sf.append(" title=").append(article.getTitle()).append(","); } if (notEmpty(article.getContent())) { sf.append(" content=").append(article.getContent()).append(","); } if (notEmpty(article.getCategory())) { sf.append(" category=").append(article.getCategory()).append(","); } if (notEmpty(article.getAuthorId())) { sf.append(" authorId=").append(article.getAuthorId()).append(","); } if (notEmpty(article.getEditorId())) { sf.append(" editorId=").append(article.getEditorId()).append(","); } if (notEmpty(article.getMediaId())) { sf.append(" mediaId=").append(article.getMediaId()).append(","); } sf.append(" uptime=").append(time.toString()).append(" where id=").append(article.getId()); logger.info(sf.toString()); int ret = jdbcTemplateWrite.update(sf.toString()); return ret > 0; }
@Override public ChargeSessionMeterReading mapRow(ResultSet rs, int rowNum) throws SQLException { ChargeSessionMeterReading row = new ChargeSessionMeterReading(); row.setSessionId(sessionId); // Row order is: created, measurand, reading, context, location, unit Timestamp ts = rs.getTimestamp(1, utcCalendar); row.setTs(new Date(ts.getTime())); row.setMeasurand(Measurand.valueOf(rs.getString(2))); row.setValue(rs.getString(3)); String s = rs.getString(4); if (s != null) { row.setContext(ReadingContext.valueOf(s)); } s = rs.getString(5); if (s != null) { row.setLocation(Location.valueOf(s)); } s = rs.getString(6); if (s != null) { row.setUnit(UnitOfMeasure.valueOf(s)); } return row; }