@Test public void testProvidedDateIsConvertedToUTC() throws Exception { ByteArrayInputStream in = new ByteArrayInputStream(TEST_EMAIL_WITH_TIMEZONE.getBytes()); Email email = new Email(in, false); assertNotNull(email.getSentDate()); assertThat(email.getHeader("Date", null), endsWith("-0700")); email.updateHeaders(); assertNotNull(email.getSentDate()); assertThat(email.getHeader("Date", null), endsWith("+0000 (GMT)")); }
@Override public void updateHeaders() throws MessagingException { super.updateHeaders(); scrubHeaders(); removeRecipientNames(); if (includeSendTime) { MailDateFormat formatter = new MailDateFormat(); formatter.setTimeZone(TimeZone.getTimeZone("GMT")); if (getSentDate() == null) setHeader("Date", formatter.format(new Date())); else setHeader("Date", formatter.format(getSentDate())); } else removeHeader("Date"); }
Email extends MimeMessage { @Override public void updateHeaders() throws MessagingException { super.updateHeaders(); scrubHeaders(); removeRecipientNames(); if (includeSendTime) { MailDateFormat formatter = new MailDateFormat(); formatter.setTimeZone(TimeZone.getTimeZone("GMT")); if (getSentDate() == null) setHeader("Date", formatter.format(new Date())); else setHeader("Date", formatter.format(getSentDate())); } else removeHeader("Date"); } }
Email extends MimeMessage { @Override public void updateHeaders() throws MessagingException { super.updateHeaders(); scrubHeaders(); removeRecipientNames(); if (includeSendTime) { MailDateFormat formatter = new MailDateFormat(); formatter.setTimeZone(TimeZone.getTimeZone("GMT")); if (getSentDate() == null) setHeader("Date", formatter.format(new Date())); else setHeader("Date", formatter.format(getSentDate())); } else removeHeader("Date"); } Email(boolean includeSendTime);  Email(InputStream emailStream, InputStream metadataStream, PasswordHolder passwordHolder);  Email(InputStream inputStream, boolean compressed);  Email(byte[] bytes);  Email(Email original); }
Email extends MimeMessage { @Override public void updateHeaders() throws MessagingException { super.updateHeaders(); scrubHeaders(); removeRecipientNames(); if (includeSendTime) { MailDateFormat formatter = new MailDateFormat(); formatter.setTimeZone(TimeZone.getTimeZone("GMT")); if (getSentDate() == null) setHeader("Date", formatter.format(new Date())); else setHeader("Date", formatter.format(getSentDate())); } else removeHeader("Date"); } Email(boolean includeSendTime);  Email(InputStream emailStream, InputStream metadataStream, PasswordHolder passwordHolder);  Email(InputStream inputStream, boolean compressed);  Email(byte[] bytes);  Email(Email original); void setContent(String text, List<Attachment> attachments); void setMetadata(EmailMetadata metadata); EmailMetadata getMetadata(); boolean isAnonymous(); String getOneFromAddress(); String getOneRecipient(); void setHashCash(HashCash hashCash); @Override void updateHeaders(); void sign(EmailIdentity senderIdentity, KeyUpdateHandler keyUpdateHandler); void setSignatureFlag(); void removeSignatureFlag(); boolean isSignatureValid(); void checkAddresses(); static void checkSender(Address address); static void checkRecipient(Address address); Collection<Address> getAllFromAddresses(); Collection<Address> getAllAddresses(boolean includeFrom); Address[] getReplyToAddresses(); String getReplyAddress(Identities identities); Address[] getToAddresses(); Address[] getCCAddresses(); Address[] getBCCAddresses(); void removeBoteSuffixes(); static String removeBoteSuffix(String addr); void setMessageID(String messageIdString); void setMessageID(UniqueId messageId); @Override String getMessageID(); void setRecent(boolean recent); boolean isRecent(); void setUnread(boolean unread); boolean isUnread(); void setCreateTime(Date createTime); boolean isDelivered(); void setReplied(boolean replied); boolean isReplied(); void setDeleted(boolean deleted); boolean isDeleted(); int getDeliveryPercentage(); Date getCreateTime(); @Override Date getReceivedDate(); @Override synchronized void setFlags(Flags flag, boolean set); @Override Flags getFlags(); Collection<UnencryptedEmailPacket> createEmailPackets(EmailIdentity senderIdentity, KeyUpdateHandler keyUpdateHandler, String bccToKeep, int maxPacketSize); String getText(); boolean isContainingAttachments(); List<Part> getParts(); @Override String toString(); }
Email extends MimeMessage { @Override public void updateHeaders() throws MessagingException { super.updateHeaders(); scrubHeaders(); removeRecipientNames(); if (includeSendTime) { MailDateFormat formatter = new MailDateFormat(); formatter.setTimeZone(TimeZone.getTimeZone("GMT")); if (getSentDate() == null) setHeader("Date", formatter.format(new Date())); else setHeader("Date", formatter.format(getSentDate())); } else removeHeader("Date"); } Email(boolean includeSendTime);  Email(InputStream emailStream, InputStream metadataStream, PasswordHolder passwordHolder);  Email(InputStream inputStream, boolean compressed);  Email(byte[] bytes);  Email(Email original); void setContent(String text, List<Attachment> attachments); void setMetadata(EmailMetadata metadata); EmailMetadata getMetadata(); boolean isAnonymous(); String getOneFromAddress(); String getOneRecipient(); void setHashCash(HashCash hashCash); @Override void updateHeaders(); void sign(EmailIdentity senderIdentity, KeyUpdateHandler keyUpdateHandler); void setSignatureFlag(); void removeSignatureFlag(); boolean isSignatureValid(); void checkAddresses(); static void checkSender(Address address); static void checkRecipient(Address address); Collection<Address> getAllFromAddresses(); Collection<Address> getAllAddresses(boolean includeFrom); Address[] getReplyToAddresses(); String getReplyAddress(Identities identities); Address[] getToAddresses(); Address[] getCCAddresses(); Address[] getBCCAddresses(); void removeBoteSuffixes(); static String removeBoteSuffix(String addr); void setMessageID(String messageIdString); void setMessageID(UniqueId messageId); @Override String getMessageID(); void setRecent(boolean recent); boolean isRecent(); void setUnread(boolean unread); boolean isUnread(); void setCreateTime(Date createTime); boolean isDelivered(); void setReplied(boolean replied); boolean isReplied(); void setDeleted(boolean deleted); boolean isDeleted(); int getDeliveryPercentage(); Date getCreateTime(); @Override Date getReceivedDate(); @Override synchronized void setFlags(Flags flag, boolean set); @Override Flags getFlags(); Collection<UnencryptedEmailPacket> createEmailPackets(EmailIdentity senderIdentity, KeyUpdateHandler keyUpdateHandler, String bccToKeep, int maxPacketSize); String getText(); boolean isContainingAttachments(); List<Part> getParts(); @Override String toString();  }