List of usage examples for javax.mail.internet MailDateFormat parse
@Override
public Date parse(String text, ParsePosition pos)
From source file:com.stimulus.archiva.domain.Email.java
public Date getReceivedDate() { MailDateFormat mdf = new MailDateFormat(); try {// w w w . ja v a2s . c o m /* Enumeration e = getAllHeaders(); while (e.hasMoreElements()) { Header h = (Header)e.nextElement(); System.out.println(h.getName()+":"+h.getValue()); }*/ String[] header = getHeader("Received"); if (header == null || header.length < 1) { return null; } for (int i = 0; i < header.length; i++) { int received = header[i].lastIndexOf(';'); if (received >= 0) { String dateStr = header[i].substring(received + 1).trim(); Date date = mdf.parse(dateStr, new ParsePosition(0)); return date; } } } catch (Exception re) { logger.debug("getReceivedDate(). unable to parse received date", re); } return null; }