79667656

Date: 2025-06-16 12:53:48
Score: 0.5
Natty:
Report link

Declare:

private static final DateTimeFormatter DTSTAMP_FORMATTER
        = DateTimeFormatter.ofPattern("uuuuMMdd'T'HHmmssX")
                .withZone(ZoneOffset.UTC);

Then do:

    ZonedDateTime zdt = ZonedDateTime.of(1996, 7, 4,
            6, 0, 0, 0, ZoneId.of("America/Mazatlan"));
    String formattedForICalendar = zdt.format(DTSTAMP_FORMATTER);
    System.out.println(formattedForICalendar);

Output is the desired:

19960704T120000Z

Use java.time for your date and time work. Joda-Time was a good library, but is in maintenance mode and officially replaced by java.time.

Links:

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: ZoƩ Mammadov