検索 API が日付をString
形式で返しています。その日付と現在の日付を比較して、何かをしたいと考えています。日付オブジェクトを作成して解析しましたが、比較するとエラーが発生します。
Calendar currentDate = Calendar.getInstance();
long dateNow = currentDate.getTimeInMillis();
String eventDate = meta.getString("startDate"); //This is the string API returns
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss.SSS");
Date date = formatter.parse(eventDate);
long modifiedDate= date.getTime();
if (dateNow.compareTo(modifiedDate)>0) {
//Do Something
}
私が得るエラーは次のとおりです。
Cannot invoke compareTo(long) on the primitive type long
ありがとう。