I've got a small Java program that I'm developing for a project, which pulls a user's inbox from a specified URI using JavaMail, and then begins processing the messages.
In Outlook, there's a function in the properties menu to set an expiry date for the message, which adds (for example):
Expiry-Date: Thu, 14 Jan 2010 17:00:00 -0000
To the message header.
Retrieving that from the email header is simple using the getHeader(String header) method from javax.mail.Message, and it returns a String[], in which happens to be the part after the colon, tokenised by spaces.
What I want to do is make this String[] into a single String, to later make into a Date. So setting up a simple foreach loop as follows:
String date = "";
for(String part : header){
date.concat(part);
}
System.out.println(date);
Now for some reason, this code returns an empty string, not entirely sure why, as this should be valid Java.
However, the following code does work, and I don't know why, as it seems illogical to me
String date = "";
for(String part : header){
date = date + part;
}
System.out.println(date);
Which prints out the correct date. Can someone tell me if this is the correct way of doing this, and if not, what's going wrong with the concat(String append) method?
TIA,
JimiF