Re. Date Formatting - Sorry for messed up last posting
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Sunday, December 22, 2002 07:06 AM

My first question is related to formatting of the date, I am using a bean to output to my jsp page. This bean generates the HTML table and fills it in as required. At present I am using this: for (int i=0, n=message.length; i { InternetAddress[] from = (InternetAddress[])message[i].getFrom(); returnString += " "; returnString += " " + from[i].getAddress() + " "; returnString += " " + message[i].getSentDate() + " "; However, I would the format to be more concise. Any help would be post appreciated. Thanks everyone!    More>>

My first question is related to formatting of the date, I am using a bean to output to my jsp page. This bean generates the HTML table and fills it in as required. At present I am using this:

			
for (int i=0, n=message.length; i
{

InternetAddress[] from = (InternetAddress[])message[i].getFrom();


returnString += "
";
returnString += " " + from[i].getAddress() + " ";
returnString += " " + message[i].getSentDate() + " ";



However, I would the format to be more concise.

Any help would be post appreciated.

Thanks everyone!    <<Less

Re: Re. Date Formatting - Sorry for messed up last posting

Posted By:   moon_departed  
Posted On:   Sunday, December 22, 2002 07:17 PM

Format to meet your request.


Address[] froms = message[i].getFrom();

if (froms == null)
return "";
StringBuffer strBuf = new StringBuffer(getDisplayAddress(froms[0]));
for (int i = 1; i < froms.length; i++) {
strBuf.append(", ").append(getDisplayAddress(froms[i]));
}
return strBuf.toString();

/*******************************************************/

public String getDisplayAddress(Address a) {
String fromName = null;
String fromAddress = null;
if (a instanceof InternetAddress &&
((fromName = ((InternetAddress)a).getPersonal()) != null)) {
fromAddress = fromName + " " + "<" +((InternetAddress)a).getAddress()+">";
} else
fromAddress = a.toString();
return fromAddress;
}


Hope this will help.
About | Sitemap | Contact