Hello,
I'm new in Java and currently developing a project which requires to use dates for some of its functionality.
When trying to get the difference between the current date vs the email was sent I'm encountering the issue below.
*****:java.text.ParseException: Unparseable date: "29 May 2014 18:34:29"
Here is what my code looks like:
1. I'm getting the date of the email was sent by using mail.header. Btw I'm coding under JBPM studio.
String messageDate = (String) mail.headers["Date"];
The outpout for this looks like this: Mon, 26 May 2014 14:37:51 +0000
2. After i gather the date I parsed it to remove the day and the timezone.
String[] l_messageDate = messageDate.split(delim : ",");
String[] l_messageDatex;
if (l_messageDate.length() > 1) {
l_messageDatex = l_messageDate[1].trim().split(delim : "+");
}
String l_messageDate1 = l_messageDatex[0].trim();
Output: 29 May 2014 18:34:29
3. After parsing I'm using the following codes to minus the current date and the date of the email.
Time l_dtCurrentDate = 'now';
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Time d1 = null;
Time d2 = null;
d1 = format.parse(l_messageDate1.trim());
d2 = format.parse((String)l_dtCurrentDate);
long diff = d2.DATE_TIME - d1.DATE_TIME;
long diff2 = d1.DATE_TIME - d2.DATE_TIME;
long diffMinutes = diff / (60 * 1000) % 60;
long diffMinutes2 = diff2 / (60 * 1000) % 60;
When the these statement run I'm encountering the said issue. I would like to request for your help in correcting my code if there are any issues.
Regards,
Kenneth