It should be

DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");

//or

DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSz");

instead of

DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyy-MM-ddTHH:mm:ss.SSSZ");

From JAVADoc:

Offset X and x: This formats the offset based on the number of pattern letters. One letter outputs just the hour, such as '+01', unless the minute is non-zero in which case the minute is also output, such as '+0130'. Two letters outputs the hour and minute, without a colon, such as '+0130'. Three letters outputs the hour and minute, with a colon, such as '+01:30'. Four letters outputs the hour and minute and optional second, without a colon, such as '+013015'. Five letters outputs the hour and minute and optional second, with a colon, such as '+01:30:15'. Six or more letters throws IllegalArgumentException. Pattern letter 'X' (upper case) will output 'Z' when the offset to be output would be zero, whereas pattern letter 'x' (lower case) will output '+00', '+0000', or '+00:00'.

Answer from ninja.coder on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › time › format › DateTimeFormatter.html
DateTimeFormatter (Java Platform SE 8 )
October 20, 2025 - Java™ Platform Standard Ed. 8 ... Formatter for printing and parsing date-time objects. This class provides the main application entry point for printing and parsing and provides common implementations of DateTimeFormatter:
🌐
Baeldung
baeldung.com › home › java › java dates › guide to datetimeformatter
Guide to DateTimeFormatter | Baeldung
March 26, 2025 - Learn how to use the Java 8 DateTimeFormatter class to format and parse dates and times
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › time › format › DateTimeFormatter.html
DateTimeFormatter (Java SE 17 & JDK 17)
January 20, 2026 - As this formatter has an optional element, it may be necessary to parse using parseBest(java.lang.CharSequence, java.time.temporal.TemporalQuery<?>...). The returned formatter has a chronology of ISO set to ensure dates in other calendar systems are correctly converted. It has no override zone and uses the STRICT resolver style. public static final DateTimeFormatter RFC_1123_DATE_TIME
🌐
Android Developers
developer.android.com › api reference › datetimeformatter
DateTimeFormatter | API reference | Android Developers
Skip to main content · English · Deutsch · Español – América Latina · Français · Indonesia · Polski · Português – Brasil · Tiếng Việt · 中文 – 简体
🌐
Medium
medium.com › @medcherrou › a-comprehensive-guide-to-date-and-time-formatting-in-java-with-datetimeformatter-fefb8e48ce9f
A Comprehensive Guide to Date and Time Formatting in Java with DateTimeFormatter | by Med Cherrou | Medium
December 13, 2024 - DateTimeFormatter is a class in the java.time.format package that helps in parsing and formatting date-time objects (LocalDate, LocalTime, LocalDateTime, ZonedDateTime, etc.).
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-time-format-datetimeformatterbuilder-class-in-java
java.time.format.DateTimeFormatterBuilder Class in Java - GeeksforGeeks
July 23, 2025 - // Java program to illustrate DateTimeFormatterBuilder // Using optionalStart() and optionalEnd() Methods // Importing required libraries import java.io.*; import java.lang.*; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.temporal.ChronoField; // Main class public class GFG { // Main driver methods public static void main(String[] args) { // Creating an object of DateTimeFormatter class DateTimeFormatter parser = new DateTimeFormatterBuilder() .appendPattern("[yyyy][yyyyM
Find elsewhere
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › time › format › DateTimeFormatter.html
DateTimeFormatter (Java SE 21 & JDK 21)
January 20, 2026 - As this formatter has an optional element, it may be necessary to parse using parseBest(java.lang.CharSequence, java.time.temporal.TemporalQuery<?>...). The returned formatter has a chronology of ISO set to ensure dates in other calendar systems are correctly converted. It has no override zone and uses the STRICT resolver style. public static final DateTimeFormatter RFC_1123_DATE_TIME
🌐
How to do in Java
howtodoinjava.com › home › java date time › java datetimeformatter (with examples)
Java DateTimeFormatter (with Examples)
June 11, 2024 - Java DateTimeFormatter helps in uniformly parsing and printing the date-time objects in various inbuilt and custom formatting patterns.
🌐
Joda
joda.org › joda-time › apidocs › org › joda › time › format › DateTimeFormatter.html
DateTimeFormatter (Joda-Time 2.14.0 API)
java.lang.Object · org.joda.time.format.DateTimeFormatter · public class DateTimeFormatter extends Object · Controls the printing and parsing of a datetime to and from a string. This class is the main API for printing and parsing used by most applications.
🌐
Coderanch
coderanch.com › t › 772301 › java › Java-Time-Parsing-Date-Format
Using Java Time Parsing a Date to Specified Format (Java in General forum at Coderanch)
May 1, 2023 - Steve Dyke wrote:The date I am getting from a remote data source example 01/03/2022 I want to change it to this format: 2023-01-01 The following code gives me an error: java.time.format.DateTimeParseException: Text '01/03/2022' could not be parsed at index 0 You would need to parse it with "MM/dd/uuuu".
🌐
Java Guides
javaguides.net › 2024 › 06 › java-datetimeformatter.html
Java DateTimeFormatter
June 30, 2024 - The DateTimeFormatter class in Java is a versatile tool for formatting and parsing date-time objects. It supports both predefined and custom formats, allowing for flexible date and time handling.
🌐
Scijava
javadoc.scijava.org › Java9 › java › time › format › class-use › DateTimeFormatter.html
Uses of Class java.time.format.DateTimeFormatter (Java SE 9 & JDK 9 )
Report a bug or suggest an enhancement For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
🌐
Javaplanet
javaplanet.io › home › java.time › datetimeformatter
DateTimeFormatter -
September 12, 2025 - import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; public class FormatterExample { public static void main(String[] args) { LocalDateTime now = LocalDateTime.now(); DateTimeFormatter customFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss"); String formatted = now.format(customFormatter); System.out.println("Current Date-Time (formatted): " + formatted); } }
🌐
Date Time Formatter
datetimeformatter.com › how-to-format-date-time-in-java-8
How to Format Date Time In Java 8 - Date Time Formatter
Java 8 Date Time Formatting Overview Java 8 no longer uses the SimpleDateFormat Class that was used in Java SE 7. Java SE 8 implements a class called DateTimeFormatter that allows you to print and parse date time objects. If you are looking to format datetime in Android or Kotlin, please check ...
🌐
Adobe Developer
developer.adobe.com › experience-manager › reference-materials › 6-5 › javadoc › org › joda › time › format › DateTimeFormatter.html
DateTimeFormatter (The Adobe AEM Quickstart and Web Application.)
java.lang.Object · org.joda.time.format.DateTimeFormatter · public class DateTimeFormatter extends java.lang.Object · Controls the printing and parsing of a datetime to and from a string. This class is the main API for printing and parsing used by most applications.
🌐
Dariawan
dariawan.com › tutorials › java › java-datetimeformatter-tutorial-examples
Java DateTimeFormatter Tutorial with Examples | Dariawan
September 3, 2019 - DateTimeFormatter class is a formatter for printing and parsing date-time objects since the introduction of Java 8 date time API.
🌐
W3Schools
w3schools.com › java › java_date.asp
Java Date and Time
import java.time.LocalDateTime; // Import the LocalDateTime class import java.time.format.DateTimeFormatter; // Import the DateTimeFormatter class public class Main { public static void main(String[] args) { LocalDateTime myDateObj = LocalDateTime.now(); System.out.println("Before formatting: " + myDateObj); DateTimeFormatter myFormatObj = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss"); String formattedDate = myDateObj.format(myFormatObj); System.out.println("After formatting: " + formattedDate); } } The output will be: Try it Yourself » ·
🌐
Java67
java67.com › 2019 › 01 › 10-examples-of-format-and-parse-dates-in-java.html
10 Examples to DateTimeFormatter in Java 8 to Parse, Format LocalDate and LocalTime | Java67
June 16, 2016 - If you want to learn more, you can also see the What's New in Java 8 course on Pluralsight. Japanese use a different date format than the UK and USA; they put the year first followed by month and day. You can define both long and short date formats for Japan using patterns "yyyy-MM-dd" and "yy-MM-dd" as shown in the below example · DateTimeFormatter japan = DateTimeFormatter.ofPattern("yy-MM-dd"); String japanese = now.format(japan); System.out.println("Date in Japan dateformat : " + japanese); Output Date in Japan date format: 16-06-16