testing code on new server, java.time.localdatetime cannot be converted to date does not happen in production

Viewed 625
  • I am setting up a development server on an AWS AMI with ColdFusion 2018 and mariadb 10.5.4

  • I did not find out what the current production versions were but it is highly possible they were somewhat older. The application was launched in 2016

  • The code is unchanged from production, the database is a direct backup and restore, no changes *I am getting errors in the code in cfoutput query when it trys to format the field Named: DateStamp. This is one example of the code that errors, it is in many places:

    #DateFormat(Q.DateStamp,"m/d/yyyy")# #TimeFormat(Q.DateStamp, "short")#
    
  • This is the error

    • "The value class java.time.LocalDateTime cannot be converted to a date"
  • The table in mariadb has the datatype of DateStamp as datetime, this is unchanged from production

I don't know why this is expecting the field to be a LocalDateTime when it is a regular DateTime. It has to be something in the configuration of this environment but I'm having trouble understanding what? I have searched but all I get is "how to handle LocalDateTime" type of links so no help as I can't change all the code when this is a test environment that must at least start with the same code as production

2 Answers

As per my comment on Adrian's contribution - in cases like this the answer is often found by comparing the datasource configuration between environments - most importantly whether the same DB driver was chosen in both, and then the various advanced settings on the datasource, and finally any version/compatibility settings on the DB server itself.

You need to find out which versions of ACF, MySQL and Java are running in production. Even if the application was launched in 2016, there's no guarantee it was released on CF 2016. Could be an older version of the server.

select Q.DateStamp from where <id = a single>
example looks like "2016-10-17 17:50:34"

Did you run the query in an IDE or did you run this through a cfquery. Need to make sure that it's returning as a DateTime object ({ts '2012-12-12 12:12:12'}) and not a string.

java.time.localDateTime

A date-time without a time-zone in the ISO-8601 calendar system, such as 2007-12-03T10:15:30.

MariaDB DateTime

MariaDB displays DATETIME values in 'YYYY-MM-DD HH:MM:SS.ffffff'

Related