Understanding `yyyy-MM-dd HH:mm:ss` and `SSSXXX`

yyyy-mm-dd hh:mm:ss is shorthand for a date and time written as year-month-day followed by hours, minutes, and seconds, such as 2026-07-16 19:20:30. In Java formatter syntax, capitalization matters: yyyy-MM-dd HH:mm:ss uses months and a 24-hour clock, while .SSSXXX adds milliseconds and a UTC offset. To use these formats correctly, distinguish the timestamp’s written structure from the programming language’s formatting tokens.

How to Read the Date and Time

Consider this timestamp:

2026-07-16 19:20:30

The date is July 16, 2026, and the time is 7:20:30 p.m. The hyphens separate the date fields, the colons separate the time fields, and a space separates the date from the time.

In standards-style date-time notation:

  • YYYY represents the year.
  • MM represents the month.
  • DD represents the day of the month.
  • hh represents a two-digit hour from 00 through 23, with no AM/PM marker.
  • mm represents a two-digit minute from 00 through 59.
  • ss represents a two-digit second from 00 through 59.

Those letters describe fields; they are not a universal programming syntax. Java, Python, and JavaScript do not all interpret them the same way.

The example also has an important limitation: it contains no UTC offset or time-zone identifier. It expresses a calendar date and wall-clock time, but it does not identify a unique instant worldwide. A database, application, or external agreement might supply that missing context.

How to Format and Parse a Timestamp Correctly

A space-separated Java formatting pattern is not interchangeable with the W3C date-time profile.

Oracle Big Data Discovery’s Java-style example uses yyyy-MM-dd HH:mm:ss. The W3C date-time profile, by contrast, uses YYYY-MM-DDThh:mm:ssTZD for a date-time with seconds: it includes both a literal T and a time-zone designator.

What You Need Example Output Java DateTimeFormatter Pattern
A local date and time, with its zone established elsewhere 2026-07-16 19:20:30 yyyy-MM-dd HH:mm:ss
A timestamp with seconds and a numeric UTC offset 1997-07-16T19:20:30+01:00 yyyy-MM-dd'T'HH:mm:ssXXX
A timestamp with milliseconds and a UTC offset 2026-07-16T19:20:30.123+01:00 yyyy-MM-dd'T'HH:mm:ss.SSSXXX

Step 1: Identify What the Receiving System Requires

  1. Determine whether the destination expects a space or T between the date and time, whether fractional seconds are allowed, and whether an offset is required.
  2. Choose a data type that preserves the information you actually have. In Java, LocalDateTime represents a date and time without an offset; OffsetDateTime includes an offset.
  3. If the source has no offset, establish its time zone before converting it to an instant. Do not assume that an unqualified timestamp is UTC.

A named time zone and a UTC offset are different things. A zone such as America/New_York contains historical and daylight-saving rules; an offset such as -04:00 supplies only the difference from UTC for that timestamp.

If a local time falls in a daylight-saving overlap or gap, the application needs an explicit rule for resolving it. Formatting alone cannot supply that missing decision.

Step 2: Use the Correct Java Tokens

  1. Use MM for the month and mm for minutes. A lowercase month token can produce plausible-looking but incorrect output.
  2. Use HH for a 24-hour clock. Java’s lowercase hh represents a 12-hour clock and normally needs a to distinguish AM from PM.
  3. Quote a literal T inside a Java pattern as 'T'. The quotation marks belong to the pattern; they do not appear in the output.
  4. For strict parsing with Java’s modern java.time API, prefer uuuu for the year.

The distinction between Java’s year tokens matters:

  • uuuu is the proleptic year and works directly with strict calendar-date parsing.
  • yyyy is the year of era.
  • YYYY is a week-based year, which can differ from the calendar year near New Year’s Day.

Consequently, an uppercase YYYY-MM-DD in an API document should not be pasted directly into a Java formatter. In Java, uppercase D also means day of year, not day of month.

Step 3: Convert the Time Before Changing Its Offset

  1. Preserve a supplied numeric offset when parsing the input.
  2. If the destination requires UTC, convert the represented instant to UTC.
  3. Only then serialize the result with a UTC designator.

For the numeric-offset example in the table, the conversion is:

1997-07-16T19:20:30+01:00
                       ↓ subtract one hour
1997-07-16T18:20:30Z

An offset of +01:00 means the displayed clock is one hour ahead of UTC. Subtracting that offset produces the UTC time.

Simply replacing +01:00 with Z while keeping the same clock time would change the instant. Appending Z to an unqualified local timestamp can make the same mistake.

Step 4: Parse, Format, and Verify the Result

  1. Save the following example as TimestampFormatExample.java.
  2. Compile and run it with a JDK.
  3. Confirm that it reproduces the input and prints the corresponding UTC instant.

This example uses a strict formatter for a timestamp containing milliseconds and an offset:

import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.ResolverStyle;
import java.util.Locale;
public class TimestampFormatExample {
    public static void main(String[] args) {
        DateTimeFormatter formatter = DateTimeFormatter
            .ofPattern("uuuu-MM-dd'T'HH:mm:ss.SSSXXX", Locale.ROOT)
            .withResolverStyle(ResolverStyle.STRICT);
        String input = "2026-07-16T19:20:30.123+01:00";
        OffsetDateTime parsed = OffsetDateTime.parse(input, formatter);
        String output = formatter.format(parsed);
        if (!input.equals(output)) {
            throw new IllegalStateException("Unexpected timestamp output");
        }
        System.out.println(output);
        System.out.println(parsed.toInstant());
    }
}

Compile it:

javac TimestampFormatExample.java

Run it:

java TimestampFormatExample

Expected output:

2026-07-16T19:20:30.123+01:00
2026-07-16T18:20:30.123Z

The first line verifies the chosen output format. The second verifies the UTC conversion. Invalid calendar dates fail during strict parsing rather than being silently adjusted.

The string comparison is appropriate for this example’s chosen spelling. In a general conversion pipeline, two different strings can represent the same instant, so also compare parsed instants rather than relying only on text equality.

What SSSXXX and SSSxxx Mean

In Java’s DateTimeFormatter, the suffix SSSXXX combines two independent fields:

  • SSS produces three fractional-second digits, giving millisecond resolution.
  • XXX produces a colon-separated UTC offset, or Z for a zero offset.

In the usual pattern, a decimal point precedes the fractional field:

.SSSXXX

For example, .123+01:00 means a fractional second of 123 milliseconds followed by an offset one hour ahead of UTC. These are not one combined field.

Uppercase SSS Versus Lowercase sss

Lowercase s is the seconds field in Java; lowercase sss is not the token for milliseconds. Uppercase S is the fraction-of-second field in java.time.

Fractional seconds are decimal fractions. Conceptually, .1 and .100 describe the same fraction of a second.

Choose the output precision deliberately if your application needs to preserve microseconds or nanoseconds.

These details apply to Java’s modern DateTimeFormatter. Legacy SimpleDateFormat treats S as a millisecond field, so patterns should not be transferred between the APIs without checking their semantics.

Uppercase XXX Versus Lowercase xxx

For Java’s DateTimeFormatter, both tokens produce a colon-separated numeric offset when it is nonzero. Their behavior differs at UTC:

  • XXX produces Z.
  • xxx produces +00:00.

Choose lowercase xxx when the receiving system specifically requires a numeric zero offset. Choose uppercase XXX when Z is the intended UTC representation.

The characters XXX and xxx are formatter instructions, not literal text included in the timestamp.

Decimal Points Versus Commas

Punctuation is part of the format contract. A Java pattern containing ,SSS produces a comma before the fraction, while .SSS produces a period.

The W3C profile discussed here uses a decimal point. Do not substitute a comma merely because a search phrase or local number convention uses one.

Using Timestamps in JavaScript and Python

Java pattern strings are not portable format specifications. Use each language’s date-time API rather than passing Java tokens to an unrelated formatter.

JavaScript: Normalize a Known-Valid Timestamp to UTC

JavaScript’s native Date does not use a Java-style formatting pattern. Its toISOString() method produces an ISO-style UTC timestamp with milliseconds.

For known-valid input containing an offset:

const input = "2026-07-16T19:20:30.123+01:00";
const date = new Date(input);
if (Number.isNaN(date.getTime())) {
  throw new Error("Invalid timestamp");
}
const output = date.toISOString();
if (new Date(output).getTime() !== date.getTime()) {
  throw new Error("Timestamp changed during serialization");
}
console.log(output);
// 2026-07-16T18:20:30.123Z

The output preserves the instant, not the original offset. A JavaScript Date does not retain the input’s time-zone identifier or original offset spelling.

The invalid-date check is not a strict schema validator. JavaScript parsing can normalize some out-of-range calendar inputs, so validate the required structure and calendar fields separately when processing untrusted strings. Avoid relying on native parsing of space-separated date-time strings across environments.

Python: Parse an Offset and Serialize Explicitly

Python’s strftime uses percent directives, such as %Y-%m-%d %H:%M:%S, rather than Java’s letter groups. For ISO-style timestamps, datetime.fromisoformat() and isoformat() avoid manually assembling the fields.

This example rejects an input without an offset, converts to UTC, and verifies the serialized instant:

from datetime import datetime, timezone
text = "2026-07-16T19:20:30.123+01:00"
value = datetime.fromisoformat(text)
if value.utcoffset() is None:
    raise ValueError("A UTC offset is required")
output = value.astimezone(timezone.utc).isoformat(
    timespec="milliseconds"
)
if datetime.fromisoformat(output) != value:
    raise ValueError("Timestamp changed during serialization")
print(output)
# 2026-07-16T18:20:30.123+00:00

Python emits the numeric UTC offset here rather than Z. If the receiving schema requires a different spelling, make that an explicit serialization decision.

The example input already has millisecond precision.

Meeting API and XML Timestamp Requirements

A timestamp can be meaningful and parseable yet still violate an API’s required format. Field requirements take precedence over a formatter’s convenient default output.

When creating the required recorded element in a CMS DPC attestation, provide an ISO 8601 timestamp for when the attestation was made. The documented example shape is YYYY-MM-DDThh:mm:ssZ; to generate that UTC form, convert the attestation time to UTC before serialization.

When filling the required Timestamp field in TransmissionHeader for Vermont DMV’s CVO fuel XML transmission, write the time of transmission as YYYY-MM-DDTHH:MM:SSZ. Generate the transmission timestamp in UTC, then validate the completed XML against the supplied schema before uploading it.

These documentation strings are field descriptions, not Java patterns. Their capitalization does not override the formatter rules in your programming language.

Also distinguish an example from a complete acceptance rule. An API example ending in Z does not, by itself, prove that numeric offsets or fractional seconds are forbidden. Use the field’s schema and validation rules to determine the accepted forms.

How to Check That a Timestamp Is Correct

Before sending or storing a timestamp, verify more than its appearance:

  • Calendar validity: Reject impossible dates instead of checking only character positions. A regular expression alone does not establish that a date exists.
  • Exact structure: Confirm the required separator, fractional precision, and offset spelling. A broadly accepting ISO parser may accept forms your API rejects.
  • Time-zone meaning: Ensure the offset came from the source or from a deliberate zone conversion, not from the developer machine’s default zone.
  • Precision preservation: Decide whether discarded fractional digits are acceptable.
  • Boundary behavior: Test dates around New Year’s Day to catch week-based-year mistakes, and test relevant daylight-saving transitions when converting named zones.
  • Round-trip behavior: Parse the serialized output and compare the resulting instant with the original value.

Formatting success is not proof of correctness. A mistaken month token can produce a valid-looking string, and an incorrectly appended UTC marker can produce a valid timestamp for the wrong instant.

Validate a representative payload against the receiving API or XML schema, then keep both valid and invalid examples as regression tests.

Frequently Asked Questions

What Is the hh:mm:ss Format Called?

The hh:mm:ss layout is commonly called an hours-minutes-seconds time format. Whether it represents a 12-hour or 24-hour clock depends on the notation or software: Java uses HH:mm:ss for 24-hour time and hh:mm:ss a for 12-hour time with an AM/PM marker.

How Do I Write a Date of Birth in yyyy mm dd Format?

Write the year first, then the two-digit month and day. The date-only profile is YYYY-MM-DD, so July 16, 1997 becomes 1997-07-16; if a form explicitly requires spaces, enter 1997 07 16 instead. A birth-date field normally needs only a calendar date, not a time or UTC offset.

Does dd:mm:ss.ssss Mean a Date and Time?

Not necessarily; similar notation can represent an angle in degrees, minutes, and seconds. In angular notation such as dd° mm′ ss.ssss″, the first field represents degrees, and the fractional seconds are angular seconds rather than elapsed time. Without units or a format definition, the letters and separators alone are not enough to identify the meaning.

Why is hh:mm:ss used?

The hh:mm:ss layout is used to record a time using separate hour, minute, and second fields. In standards-style 24-hour notation, hours range from 00 to 23 and minutes and seconds from 00 to 59; Java uses HH:mm:ss for this layout.

Is yyyy-MM-dd’T’HH:mm:ss the same as yyyy-MM-dd HH:mm:ss?

Do not assume that the version with T and the version with a space satisfy the same required format. Vermont’s XML guidance specifies YYYY-MM-DDTHH:MM:SSZ for a transmission timestamp, so a space would not match that stated structure. Follow the receiving system’s exact separator and suffix requirements.

What format is YYYY-MM-DDTHH:MM:SSZ?

CMS DPC documents its recorded attestation timestamp as YYYY-MM-DDThh:mm:ssZ. Vermont’s XML transmission guidance specifies YYYY-MM-DDTHH:MM:SSZ for its Timestamp field. Both forms place T between the date and time and end in Z.

What is YYYY-MM-DDTHH:MM:SS?

YYYY-MM-DDTHH:MM:SS is a date-and-time layout that puts the calendar date before T and the time through seconds after it. The W3C seconds-level profile is YYYY-MM-DDThh:mm:ssTZD, so this version leaves out the final TZD portion of that profile.