Coding⏱️ 2 min read📅 2026-06-03

How to Fix: '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp error

Error when inserting null value into timestamp column in MySQL database.

Quick Answer: Use a default value for the timestamp column that can be represented as a Java.sql.Timestamp, such as '1970-01-01 00:00:00'. Alternatively, use a custom date format to avoid issues with null values.

The issue arises because the `java.sql.Timestamp` object cannot be directly compared or assigned a value of `'0000-00-00 00:00:00'`. This is due to the fact that `java.sql.Timestamp` objects are stored in UTC timezone, while dates in MySQL are stored in the server's local timezone. When you pass a string like `'0000-00-00 00:00:00'`, it gets interpreted as a date in the server's local timezone, not UTC.

🔧 Proven Troubleshooting Steps

Method 1: Using `java.util.Date` and `Calendar` Objects

  1. Step 1: Create a `java.util.Date` object from the string `'0000-00-00 00:00:00'

Method 2: Using `java.time` Package

  1. Step 1: Parse the string into a `LocalDate` object using `LocalDateTime.parse()

To fix this issue, you can use either of these methods to convert the date string to a `java.util.Date` or `java.time.LocalDate` object.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions