Wrong data type for column
Column type is timestamp.
TIMESTAMP WITHOUT TIME ZONE, otherwise known as TIMESTAMP in Postgres, is the wrong data type for recording a moment, a point on the timeline.
👉🏽 To record a moment, you must use the type TIMESTAMP WITH TIME ZONE as it is known both in Postgres and the SQL standard.
The difference between the two types is:
TIMESTAMP WITHOUT TIME ZONE accepts any date and time you pass with no regard for time zone. So with a date-time of January 23, 2025 at 12:00, we have no idea if you meant noon in Tokyo Japan, noon in Toulouse France, or noon in Toledo Ohio US — three very different moments, several hours apart.
TIMESTAMP WITH TIME ZONE does account for time zone. If you pass only a date and a time, Postgres assumes you meant an offset of zero, and stores the value. If you pass an offset or time zone along with the date & time, Postgres uses that offset/zone to adjust into UTC (offset of zero), and then stores the value. The stored value is always in UTC. (Be aware some middleware/tools will unfortunately apply time zone dynamically after retrieval but before delivery to client!)
Avoid legacy date-time classes
The terribly-flawed date-time classes in Java have been supplanted by the modern java.time classes defined in JSR 310 and built into Java 8+.
👉🏽 Never use Date, Calendar, Timestamp, SimpleDateFormat, etc.
java.time
To capture the current moment in Java, we might use java.time.Instant. An Instant represents the moment as seen with an offset-from-UTC of zero hours-minutes-seconds.
Instant instant = Instant.now() ; // Current moment as seen in UTC.
java.time.OffsetDateTime
However, while JDBC 4.2 and later requires every JDBC driver to support the java.time classes, Instant is not mapped. Instead, JDBC maps the java.time.OffsetDateTime class to the SQL standard type TIMESTAMP WITH TIME ZONE.
👉🏽 Capture the current moment with OffsetDateTime.now.
OffsetDateTime odt = OffsetDateTime.now( ZoneOffset.UTC ) ;
Terms: An offset is merely a number of hours-minutes-seconds ahead/behind the temporal meridian of UTC. A time zone is a named (Continent/Region, ex: Europe/Paris) history of the past, present, and future changes to the offset used by the people of a particular region as decided by their politicians. The authors of the SQL standard did not understand date-time handling well, and misused the term time zone where they really meant offset.
Avoid SQL injection
You said:
String query= "UPDATE gameStatus g SET g.status ='" + gameStatus
+ g.gameStartTime= to_date('"
+ gameStartedTime + "','yyyy-MM-dd HH:mm:ss')"
👉🏽 Do not concatenate text like this to generate SQL. That bad habit will make you vulnerable to SQL Injection attacks. Instead, use parameters passed into a prepared statement.
Use objects, not text
And use smart objects rather than dumb strings. We have date-time objects in Java mapped to date-time types in SQL & Postgres. So do not convert in and out of text.
Modern Java now offers text blocks to ease the chore of writing SQL.
String sql = """
UPDATE order_
SET order_.when_ = ?
WHERE …
;
""" ;
…
myPreparedStatement.setObject( 1 , odt ) ;
You asked:
ERROR: conflicting values for "mm" field in formatting string
That issue is moot. You should not be manipulating text while exchanging date-time values between Java and Postgres.