Sample code for 30+ languages & platforms
Java

Get and Set the Email Date (Local Timezone)

See more Email Object Examples

Demonstrates the Chilkat Email.LocalDateStr property, which is the date/time from the Date header returned in the local timezone in RFC822 string form (for example, Fri, 10 Jul 2026 15:15:30 -0500). Setting this property updates the email's Date header. Use LocalDate when a native local date/time value is preferred. This example sets the date and reads it back.

Background: An RFC822 date ends with a timezone: either GMT (equivalently +0000) or a signed offset like -0500, which means five hours behind UTC. The trailing offset is the only difference between the local and GMT views — they describe the identical moment in time. LocalDateStr presents the Date header using the running computer's local offset, while EmailDateStr presents it in GMT.

Chilkat Java Downloads

Java
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    //  Demonstrates the Email.LocalDateStr property.
    //  This is the date/time from the Date header returned in the local timezone,
    //  in RFC822 string form.  Setting it updates the email's Date header.

    CkEmail email = new CkEmail();

    email.put_LocalDateStr("Fri, 10 Jul 2026 15:15:30 -0500");

    System.out.println("LocalDateStr = " + email.localDateStr());
  }
}