我已将日期格式milliseconds
和时间格式转换为milliseconds
. 我得到的当前时间超过13
digits
. CurrentTime= 1357755780000
, StartingTime=1357602840
,EndingTime=1357756140
但是当我在下面的代码中进行比较时,if
部分没有被执行,只有else
部分被执行。
我的代码有什么错误吗?我想将 currentTime 设为 10 位数字。所以我认为,将日期格式转换为毫秒是错误的。
String toParse = getDateorTime(1) + " " + getDateorTime(2);
long currentTime=0,startingTime=0,endingTime=0,milliseconds=0;
try
{
dateFormater = new SimpleDateFormat("yyyy/MMM/dd hh:mm");
Date date = null;
try {
date = dateFormater.parse(toParse);
date.setTime(milliseconds);
}catch (Exception e) {
System.out.println("\n Error in date parsing"+e.toString());
}
currentTime = (date.getTime());
start=Long.parseLong((cursor.getString(5).trim()));
end=Long.parseLong((cursor.getString(6).trim()));
}catch (ParseException pe) {
pe.printStackTrace();
}
if((currentTime>=startingTime)&&(currentTime<=endingTime))
{
//
}