我已將日期格式轉換爲milliseconds
,並將時間格式轉換爲milliseconds
。我獲得的當前時間超過13
digits
。 CurrentTime= 1357755780000
,StartingTime=1357602840
,EndingTime=1357756140
如何轉換當前日期和時間格式(以毫秒爲單位)(僅10位數字)?
但是,當我做下面的代碼相比,不執行if
部分,只有else
部分被執行。
在我的代碼中是否有任何錯誤?我想使10位數的currentTime。所以我認爲,日期格式轉換爲毫秒是錯誤的。
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))
{
//
}
嘗試發佈其餘代碼,如遊標初始化等。 – Raj