我有REPORTDATE字段,在那裏我想採取小時和分鐘的值。 reportdate.getTime()
返回此例如:1439967368798JAVA比較剛纔的時間(getTime函數)
我想比較,如果從reportdate(小時和分鐘)時間之間:
if reportdate>=06:45 and reportdate<13:45 then a=1;
if reportdate>=13:45 and reportdate<20:45 then a=2;
if reportdate>=20:45 and reportdate<06:45 then a=3;
我沒有成功找到網絡上的一些指令。 我應該使用getTime(1439967368798)或其他方法得到的值來嘗試嗎?
您應該爲此使用['Calendar'](http://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html)。 – Dragondraikk
可以使用JodaTime或Java 8的Time API,例如'LocalTime lt = new Date(1439967368798L).toInstant()。atZone(ZoneId.systemDefault())。toLocalTime();',這將允許您使用'before '和'after'(和'equals')來比較'LocalTime'的其他實例 – MadProgrammer