On 1/7/2020 1:13 PM, Jerry Malcolm wrote: > On 1/7/2020 3:09 PM, Michael Osipov wrote: >> Am 2020-01-07 um 21:58 schrieb Jerry Malcolm: >>> This may be more of a Java question than Tomcat. But I'm not sure. >>> I have the same code, talking to the same MySql Linux (AWS) >>> database. I read a date column value in a Tomcat app. After calling >>> resultSet.getDate(...) I printed the date instance and the getTime() >>> value: >>> >>> On windows: 2019-02-01 1549000800000 >>> >>> On linux: 2019-01-31 1548979200000 >>> >>> Again this is the SAME line of code in java reading the SAME field in >>> the SAME database. Only thing different is Linux/Windows OS. The >>> date is supposed to be 2/1/2019 and shows that in phpMyAdmin. >>> >>> I've been running on Linux for a few months. But I don't have an >>> extensive background in the specifics of Linux. I'm sure there must >>> be something that is configured differently. I'm at a loss. But this >>> is not a trivial problem. I do monthly billing. My dates need to be >>> accurate. >> >> Have you verified that you aren't tricked by any timezone issues? > Probably so. But how would I know? I was under the impression that > java.sql.Date was timezone independent. Shouldn't it simply convert a > month/day/year value to the number of milliseconds since the epoch? How > would timezone issues affect that? And if I am 'tricked' how do I > 'untrick'. What do I set/change?
According to the AWS documentation, there are two places that you have to set manually in order to get the timezone changed universally. 1. /etc/sysconfig/clock This you've already changed correctly. 2. /etc/localtime According to the documentation, you'll need to link /etc/localtime to the appropriate /usr/share/zoneinfo/America timezone file - most likely Chicago. sudo ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime Also, do you have chrony installed and running on your Linux instance? This is an NTP replacement that the AWS documentation recommends, and will sync your time with AWS time servers. Once you do all of this, you'll have to reboot. Here's a link to the documentation: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-time.html For what it's worth, the following quick and dirty code (note, no packages, ma) prints out the correct timezone (Pacific Standard Time) before I made the link and rebooted the machine. Here's the code (no package, bad programming practice). tz.java: import java.util.TimeZone; public class tz { public static void main(String[] args) { System.out.println(TimeZone.getDefault().getDisplayName()); } } $ javac tz.java $ java -cp . tz Pacific Standard Time $ As an aside, on my CentOS 6 system, there are notes in the /etc/sysconfig/clock file: # The time zone of the system is defined by the contents of /etc/localtime. # This file is only for evaluation by system-config-date, do not rely on its # contents elsewhere. So I suspect that part of your system thinks it's UTC and part CST/CDT? . . . just my two cents. /mde/
signature.asc
Description: OpenPGP digital signature