我如何比较是否mytime
在fromtime
和之间totime
:
Timestamp fromtime;
Timestamp totime;
Timestamp mytime;
Run Code Online (Sandbox Code Playgroud)
leg*_*ess 61
if(mytime.after(fromtime) && mytime.before(totime))
//mytime is in between
Run Code Online (Sandbox Code Playgroud)
Jea*_*art 15
使用before
和after
方法:Javadoc
if (mytime.after(fromtime) && mytime.before(totime))
Run Code Online (Sandbox Code Playgroud)
来自:http://download.oracle.com/javase/6/docs/api/java/sql/Timestamp.html#compareTo(java.sql.Timestamp)
public int compareTo(Timestamp ts)
Run Code Online (Sandbox Code Playgroud)
将此Timestamp对象与给定的Timestamp对象进行比较.参数:ts - 要与此Timestamp对象进行比较的Timestamp对象返回:如果两个Timestamp对象相等,则返回值0;否则返回0.如果此Timestamp对象在给定参数之前,则小于0的值; 如果此Timestamp对象位于给定参数之后,则值大于0.自:1.4
归档时间: |
|
查看次数: |
118279 次 |
最近记录: |