java.sql.Timestamp#after ( )源码实例Demo

下面列出了java.sql.Timestamp#after ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: scipio-erp   文件: TechDataServices.java
/** Used to request the remaining capacity available for dateFrom in a TechDataCalenda,
 * If the dateFrom (param in) is not  in an available TechDataCalendar period, the return value is zero.
 *
 * @param techDataCalendar        The TechDataCalendar cover
 * @param dateFrom                        the date
 * @return  long capacityRemaining
 */
public static long capacityRemainingBackward(GenericValue techDataCalendar,  Timestamp  dateFrom) {
    GenericValue techDataCalendarWeek = null;
    // TODO read TechDataCalendarExcWeek to manage exception week (maybe it's needed to refactor the entity definition
    try {
        techDataCalendarWeek = techDataCalendar.getRelatedOne("TechDataCalendarWeek", true);
    } catch (GenericEntityException e) {
        Debug.logError("Pb reading Calendar Week associated with calendar"+e.getMessage(), module);
        return 0;
    }
    // TODO read TechDataCalendarExcDay to manage execption day
    Calendar cDateTrav =  Calendar.getInstance();
    cDateTrav.setTime(dateFrom);
    Map<String, Object> position = dayEndCapacityAvailable(techDataCalendarWeek, cDateTrav.get(Calendar.DAY_OF_WEEK));
    int moveDay = (Integer) position.get("moveDay");
    if (moveDay != 0) return 0;
    Time startTime = (Time) position.get("startTime");
    Double capacity = (Double) position.get("capacity");
    Timestamp startAvailablePeriod = new Timestamp(UtilDateTime.getDayStart(dateFrom).getTime() + startTime.getTime() + cDateTrav.get(Calendar.ZONE_OFFSET) + cDateTrav.get(Calendar.DST_OFFSET));
    if (dateFrom.before(startAvailablePeriod)) return 0;
    Timestamp endAvailablePeriod = new Timestamp(startAvailablePeriod.getTime()+capacity.longValue());
    if (dateFrom.after(endAvailablePeriod)) return 0;
    return  dateFrom.getTime() - startAvailablePeriod.getTime();
}
 
源代码2 项目: mytwitter   文件: MessageServlet.java
public void formatDate(Messageall messageall, Timestamp ttime) {
	SimpleDateFormat sdf = new SimpleDateFormat("MM-dd");
	SimpleDateFormat sdf2 = new SimpleDateFormat("yy-MM-dd");

	Calendar cal = Calendar.getInstance();
	int year = cal.get(Calendar.YEAR);

	String nowyear = year + "-01-01 00:00:00";
	Timestamp yeardate = Timestamp.valueOf(nowyear);

	if (ttime.after(yeardate)) {
		messageall.setTime(sdf.format(ttime));
	} else {
		messageall.setTime(sdf2.format(ttime));
	}
}
 
源代码3 项目: scipio-erp   文件: UtilValidate.java
public static boolean isDateAfterNow(Timestamp  date) {
    Timestamp now = UtilDateTime.nowTimestamp();
    if (date != null) {
        return date.after(now);
    }
    return false;
}
 
源代码4 项目: gemfirexd-oss   文件: TimeHandlingTest.java
/**
 * Check the consistency of a ResultSet column that returns
 * CURRENT TIMESTAMP or a value set from CURRENT TIMESTAMP.
 * 
 * @param start Time the statement settng the value was executed
 * @param end Time after first rs.next() or update statement was executed
 * @param rs ResultSet holding the column, positioned on a row
 * @param column Column with the timestamp.
 * @return Returns the Timestamp object obtained from the column.
 * @throws SQLException
 */
private Timestamp checkCurrentTimestampValue(long start, long end,
        ResultSet rs, int column) throws SQLException
{       
    Timestamp tsv = checkTimestampValue(rs, column);

    // The time returned should be between the value
    // of start and end (inclusive of both)
    
    Timestamp st = new Timestamp(start);
    Timestamp et = new Timestamp(end);
    
    
    if (st.after(et)) {
        // Gone back in time!
        // Well test was running around midnight and the
        // time for the start time is equal to or before 23:59:59
        // and end time is equal to or after  00:00:00
        
        assertTrue("CURRENT TIME outside of range when test crossing midnight",
           (tsv.equals(st) || tsv.after(st))
           || (tsv.equals(et) || tsv.before(et)));
    }
    else
    {
        // End time is after or equal to start time, expected case.

        // The returned time must not be before the
        // start time or after the end time.
        assertFalse("CURRENT TIME before start of statement", tsv.before(st));
        assertFalse("CURRENT TIME after end of statement", tsv.after(et));       
    }
    
    return tsv;
}
 
源代码5 项目: scipio-erp   文件: EntitySyncContext.java
protected Timestamp getNextRunEndTime() {
    long syncSplit = this.isOfflineSync ? offlineSyncSplitMillis : syncSplitMillis;
    Timestamp nextRunEndTime = new Timestamp(this.currentRunStartTime.getTime() + syncSplit);
    if (nextRunEndTime.after(this.syncEndStamp)) {
        nextRunEndTime = this.syncEndStamp;
    }
    return nextRunEndTime;
}
 
private Timestamp getLatestTimestamp(Timestamp date1, Timestamp date2) {
	
	if (date1 != null && date2 == null) 
		return date1;
	if (date1 == null && date2 != null) 
		return date2;
	if (date1.after(date2))
		return date1;
	
	return date2;
}
 
源代码7 项目: reladomo   文件: AsOfAttribute.java
public boolean asOfDateMatchesRange(Timestamp asOfDate, Timestamp from, Timestamp to)
{
    if (asOfDate.equals(this.getInfinityDate()))
    {
        return to.equals(this.getInfinityDate());
    }
    else
    {
        if (to.after(asOfDate) || (this.isToIsInclusive() && to.equals(asOfDate)))
        {
            return from.before(asOfDate) || (!this.isToIsInclusive() && from.equals(asOfDate));
        }
    }
    return false;
}
 
源代码8 项目: reladomo   文件: AsOfAttribute.java
public static boolean isMilestoningValid(Object obj, AsOfAttribute[] asOfAttributes)
{
    for (AsOfAttribute asOfAttribute : asOfAttributes)
    {
        Timestamp from = asOfAttribute.getFromAttribute().valueOf(obj);
        Timestamp to = asOfAttribute.getToAttribute().valueOf(obj);
        if (from.equals(to) || from.after(to))
        {
            return false;
        }
    }
    return true;
}
 
源代码9 项目: scipio-erp   文件: ProductWorker.java
public static boolean isSellable(GenericValue product, Timestamp atTime) {
    if (product != null) {
        Timestamp introDate = product.getTimestamp("introductionDate");
        Timestamp discDate = product.getTimestamp("salesDiscontinuationDate");
        if (introDate == null || introDate.before(atTime)) {
            if (discDate == null || discDate.after(atTime)) {
                return true;
            }
        }
    }
    return false;
}
 
源代码10 项目: envelope   文件: TimestampTimeModel.java
@Override
public int compare(Row first, Row second) {
  Timestamp ts1 = first.getAs(field.name());
  Timestamp ts2 = second.getAs(field.name());
  
  if (ts1.before(ts2)) {
    return -1;
  } else if (ts1.after(ts2)) {
    return 1;
  } else {
    return 0;
  }
}
 
源代码11 项目: jdk8u_jdk   文件: TimestampTests.java
@Test(expectedExceptions = NullPointerException.class)
public void test22() throws Exception {
    Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
    ts1.after(null);
}
 
源代码12 项目: TencentKona-8   文件: TimestampTest.java
/**
 * Compares two Timestamps with the expected result.
 *
 * @param ts1 the first Timestamp
 * @param ts2 the second Timestamp
 * @param expect the expected relation between ts1 and ts2; 0 if
 * ts1 equals to ts2, or 1 if ts1 is after ts2, or -1 if ts1 is
 * before ts2.
 */
private void compareTimestamps(Timestamp ts1, Timestamp ts2, int expected) {
    boolean expectedResult = expected > 0;
    boolean result = ts1.after(ts2);
    if (result != expectedResult) {
        errln("ts1.after(ts2) returned " + result
              + ". (ts1=" + ts1 + ", ts2=" + ts2 + ")");
    }

    expectedResult = expected < 0;
    result = ts1.before(ts2);
    if (result != expectedResult) {
        errln("ts1.before(ts2) returned " + result
              + ". (ts1=" + ts1 + ", ts2=" + ts2 + ")");
    }

    expectedResult = expected == 0;
    result = ts1.equals(ts2);
    if (result != expectedResult) {
        errln("ts1.equals(ts2) returned " + result
              + ". (ts1=" + ts1 + ", ts2=" + ts2 + ")");
    }

    int x = ts1.compareTo(ts2);
    int y = (x > 0) ? 1 : (x < 0) ? -1 : 0;
    if (y != expected) {
        errln("ts1.compareTo(ts2) returned " + x + ", expected "
              + relation(expected, "") + "0"
              + ". (ts1=" + ts1 + ", ts2=" + ts2 + ")");
    }
    long t1 = ts1.getTime();
    long t2 = ts2.getTime();
    int z = (t1 > t2) ? 1 : (t1 < t2) ? -1 : 0;
    if (z == 0) {
        int n1 = ts1.getNanos();
        int n2 = ts2.getNanos();
        z = (n1 > n2) ? 1 : (n1 < n2) ? -1 : 0;
    }
    if (z != expected) {
        errln("ts1.getTime() " + relation(z, "==") + " ts2.getTime(), expected "
              + relation(expected, "==")
              + ". (ts1=" + ts1 + ", ts2=" + ts2 + ")");
    }
}
 
源代码13 项目: jdk8u60   文件: TimestampTests.java
@Test(expectedExceptions = NullPointerException.class)
public void test22() throws Exception {
    Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
    ts1.after(null);
}
 
源代码14 项目: ApprovalTests.Java   文件: AddDateAware.java
public boolean isExtracted(AddDateAware object) throws IllegalArgumentException
{
  ObjectUtils.assertInstance(AddDateAware.class, object);
  Timestamp addDate = ((AddDateAware) object).getAddDate();
  return (addDate == null) ? false : !addDate.after(date);
}
 
源代码15 项目: openjdk-jdk9   文件: TimestampTest.java
/**
 * Compares two Timestamps with the expected result.
 *
 * @param ts1 the first Timestamp
 * @param ts2 the second Timestamp
 * @param expect the expected relation between ts1 and ts2; 0 if
 * ts1 equals to ts2, or 1 if ts1 is after ts2, or -1 if ts1 is
 * before ts2.
 */
private void compareTimestamps(Timestamp ts1, Timestamp ts2, int expected) {
    boolean expectedResult = expected > 0;
    boolean result = ts1.after(ts2);
    if (result != expectedResult) {
        errln("ts1.after(ts2) returned " + result
              + ". (ts1=" + ts1 + ", ts2=" + ts2 + ")");
    }

    expectedResult = expected < 0;
    result = ts1.before(ts2);
    if (result != expectedResult) {
        errln("ts1.before(ts2) returned " + result
              + ". (ts1=" + ts1 + ", ts2=" + ts2 + ")");
    }

    expectedResult = expected == 0;
    result = ts1.equals(ts2);
    if (result != expectedResult) {
        errln("ts1.equals(ts2) returned " + result
              + ". (ts1=" + ts1 + ", ts2=" + ts2 + ")");
    }

    int x = ts1.compareTo(ts2);
    int y = (x > 0) ? 1 : (x < 0) ? -1 : 0;
    if (y != expected) {
        errln("ts1.compareTo(ts2) returned " + x + ", expected "
              + relation(expected, "") + "0"
              + ". (ts1=" + ts1 + ", ts2=" + ts2 + ")");
    }
    long t1 = ts1.getTime();
    long t2 = ts2.getTime();
    int z = (t1 > t2) ? 1 : (t1 < t2) ? -1 : 0;
    if (z == 0) {
        int n1 = ts1.getNanos();
        int n2 = ts2.getNanos();
        z = (n1 > n2) ? 1 : (n1 < n2) ? -1 : 0;
    }
    if (z != expected) {
        errln("ts1.getTime() " + relation(z, "==") + " ts2.getTime(), expected "
              + relation(expected, "==")
              + ". (ts1=" + ts1 + ", ts2=" + ts2 + ")");
    }
}
 
源代码16 项目: jdk8u-jdk   文件: TimestampTests.java
@Test(expectedExceptions = NullPointerException.class)
public void test22() throws Exception {
    Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
    ts1.after(null);
}
 
源代码17 项目: mytwitter   文件: TweetServletTwo.java
public String roll(List<Utweets> tweetsList, int uid) {
	JSONArray js = new JSONArray();
	for (Utweets utweets : tweetsList) {

		if (utweets.getTzhuan() > 0) {
			Forwards forward = forwardsDao.getForward(utweets.getTid(), utweets.getTtime());
			int id = forward.getStid();
			Utweets utweet = tweetsDao.getTweetsByTid(id);
			utweets.setUtweets(utweet);
		}

		int tid = utweets.getTid();
		boolean zhuaned = forwardsDao.selForward(uid, tid);
		if (zhuaned == true)
			utweets.setZhuaned(1);
		else
			utweets.setZhuaned(0);

		boolean zaned = likesDao.selLike(uid, tid);
		if (zaned == true)
			utweets.setZaned(1);
		else
			utweets.setZaned(0);

		Timestamp ttime = utweets.getTtime();
		SimpleDateFormat sdf = new SimpleDateFormat("MM月dd日 HH:mm");
		SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
		SimpleDateFormat sdf3 = new SimpleDateFormat("HH:mm");
		Calendar cal = Calendar.getInstance();
		int day = cal.get(Calendar.DATE);
		int month = cal.get(Calendar.MONTH) + 1;
		int year = cal.get(Calendar.YEAR);

		String nowyear = year + "-01-01 00:00:00";
		Timestamp yeardate = Timestamp.valueOf(nowyear);

		String nowday = year + "-" + month + "-" + day + " 00:00:00";
		Timestamp date = Timestamp.valueOf(nowday);
		// 此处转换为毫秒数
		long millionSeconds = ttime.getTime();// 毫秒
		long nowSeconds = System.currentTimeMillis();
		long chazhi = nowSeconds - millionSeconds;

		if (chazhi < 60000) {
			utweets.setTime("现在");
		} else if (chazhi < 3600000) {
			long n = chazhi / 60000;
			utweets.setTime(n + "分钟");
		} else if (ttime.after(date)) {
			utweets.setTime(sdf3.format(ttime));
		} else if (ttime.after(yeardate)) {
			utweets.setTime(sdf.format(ttime));
		} else {
			utweets.setTime(sdf2.format(ttime));
		}
		js.add(getJsonObj(utweets.getTid(), utweets.getUid(), utweets.getTcontent(), utweets.getTpic(),
				utweets.getTvideo(), utweets.getTreply(), utweets.getTforward(), utweets.getTlike(),
				utweets.getUname(), utweets.getUpwd(), utweets.getUrealname(), utweets.getUaite(),
				utweets.getUonline(), utweets.getUabout(), utweets.getUlogo(), utweets.getUbg(), utweets.getUfans(),
				utweets.getUtweet(), utweets.getUfollow(), utweets.getUcolor(), utweets.getTime(),
				utweets.getUtweets(), utweets.getTzhuan(), utweets.getZaned(), utweets.getZhuaned()));
	}
	return js.toString();
}
 
源代码18 项目: mytwitter   文件: ReplyServlet.java
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	req.setCharacterEncoding("UTF-8");
	resp.setContentType("text/html;charset=UTF-8");
	String page = req.getParameter("page");
	String tid = req.getParameter("tid");
	List<Replyall> replys = replysDao.getAllReply(Integer.parseInt(tid), Integer.parseInt(page));
	if (replys == null) {
		return;
	}
	JSONArray js = new JSONArray();
	for (Replyall reply : replys) {
		Timestamp rtime = reply.getRtime();
		SimpleDateFormat sdf = new SimpleDateFormat("MM月dd日 HH:mm");
		SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
		SimpleDateFormat sdf3 = new SimpleDateFormat("HH:mm");
		Calendar cal = Calendar.getInstance();
		int day = cal.get(Calendar.DATE);
		int month = cal.get(Calendar.MONTH) + 1;
		int year = cal.get(Calendar.YEAR);

		String nowyear = year + "-01-01 00:00:00";
		Timestamp yeardate = Timestamp.valueOf(nowyear);

		String nowday = year + "-" + month + "-" + day + " 00:00:00";
		Timestamp date = Timestamp.valueOf(nowday);
		// 此处转换为毫秒数
		long millionSeconds = rtime.getTime();// 毫秒
		long nowSeconds = System.currentTimeMillis();
		long chazhi = nowSeconds - millionSeconds;

		if (chazhi < 60000) {
			reply.setTime("现在");
		} else if (chazhi < 3600000) {
			long n = chazhi / 60000;
			reply.setTime(n + "分钟");
		} else if (rtime.after(date)) {
			reply.setTime(sdf3.format(rtime));
		} else if (rtime.after(yeardate)) {
			reply.setTime(sdf.format(rtime));
		} else {
			reply.setTime(sdf2.format(rtime));
		}

		js.add(getJsonObj(reply.getRid(), reply.getUid(), reply.getTid(), reply.getRcontent(), reply.getTime(),
				reply.getUname(), reply.getUrealname(), reply.getUaite(), reply.getUlogo()));
	}
	resp.getWriter().print(js.toString());
}
 
源代码19 项目: hottub   文件: TimestampTests.java
@Test(expectedExceptions = NullPointerException.class)
public void test22() throws Exception {
    Timestamp ts1 = Timestamp.valueOf("1966-08-30 08:08:08");
    ts1.after(null);
}
 
源代码20 项目: scipio-erp   文件: TechDataServices.java
/**
 *
 * Used to check if there is not two routing task with the same SeqId valid at the same period
 *
 * @param ctx            The DispatchContext that this service is operating in.
 * @param context    a map containing workEffortIdFrom (routing) and SeqId, fromDate thruDate
 * @return result      a map containing sequenceNumNotOk which is equal to "Y" if it's not Ok
 */
public static Map<String, Object> checkRoutingTaskAssoc(DispatchContext ctx, Map<String, ? extends Object> context) {
    Delegator delegator = ctx.getDelegator();
    Map<String, Object> result = new HashMap<String, Object>();
    String sequenceNumNotOk = "N";
    Locale locale = (Locale) context.get("locale");
    String workEffortIdFrom = (String) context.get("workEffortIdFrom");
    String workEffortIdTo = (String) context.get("workEffortIdTo");
    String workEffortAssocTypeId = (String) context.get("workEffortAssocTypeId");
    Long sequenceNum =  (Long) context.get("sequenceNum");
    Timestamp fromDate = (Timestamp) context.get("fromDate");
    Timestamp thruDate = (Timestamp) context.get("thruDate");
    String create = (String) context.get("create");

    boolean createProcess = (create !=null && "Y".equals(create)) ? true : false;
    List<GenericValue> listRoutingTaskAssoc = null;

    try {
        listRoutingTaskAssoc = EntityQuery.use(delegator).from("WorkEffortAssoc")
                .where("workEffortIdFrom", workEffortIdFrom,"sequenceNum",sequenceNum)
                .orderBy("fromDate")
                .queryList();
    } catch (GenericEntityException e) {
        Debug.logWarning(e, module);
        return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingTechDataWorkEffortAssocNotExist", UtilMisc.toMap("errorString", e.toString()), locale));
    }

    if (listRoutingTaskAssoc != null) {
        for (GenericValue routingTaskAssoc : listRoutingTaskAssoc) {
            if (! workEffortIdFrom.equals(routingTaskAssoc.getString("workEffortIdFrom")) ||
            ! workEffortIdTo.equals(routingTaskAssoc.getString("workEffortIdTo")) ||
            ! workEffortAssocTypeId.equals(routingTaskAssoc.getString("workEffortAssocTypeId")) ||
            ! sequenceNum.equals(routingTaskAssoc.getLong("sequenceNum"))
           ) {
                if (routingTaskAssoc.getTimestamp("thruDate") == null && routingTaskAssoc.getTimestamp("fromDate") == null) sequenceNumNotOk = "Y";
                else if (routingTaskAssoc.getTimestamp("thruDate") == null) {
                    if (thruDate == null) sequenceNumNotOk = "Y";
                    else if (thruDate.after(routingTaskAssoc.getTimestamp("fromDate"))) sequenceNumNotOk = "Y";
                }
                else  if (routingTaskAssoc.getTimestamp("fromDate") == null) {
                    if (fromDate == null) sequenceNumNotOk = "Y";
                    else if (fromDate.before(routingTaskAssoc.getTimestamp("thruDate"))) sequenceNumNotOk = "Y";
                }
                else if (fromDate == null && thruDate == null) sequenceNumNotOk = "Y";
                else if (thruDate == null) {
                    if (fromDate.before(routingTaskAssoc.getTimestamp("thruDate"))) sequenceNumNotOk = "Y";
                }
                else if (fromDate == null) {
                    if (thruDate.after(routingTaskAssoc.getTimestamp("fromDate"))) sequenceNumNotOk = "Y";
                }
                else if (routingTaskAssoc.getTimestamp("fromDate").before(thruDate) && fromDate.before(routingTaskAssoc.getTimestamp("thruDate"))) sequenceNumNotOk = "Y";
            } else if (createProcess) sequenceNumNotOk = "Y";
        }
    }
    result.put("sequenceNumNotOk", sequenceNumNotOk);
    return result;
}