-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Changed timestamp of item insert from MySql server time to local Java… #4503
Conversation
@@ -421,15 +421,20 @@ public void store(Item item, String alias) { | |||
String sqlCmd = null; | |||
PreparedStatement statement = null; | |||
try { | |||
// Get current timestamp | |||
long timeNow = Calendar.getInstance().getTimeInMillis(); | |||
java.sql.Timestamp timestamp = new java.sql.Timestamp(timeNow); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation (consider using the Eclipse IDE to auto-format code). Also, please import java.sql.Timestamp and use here without package qualifier.
Thanks for this. What are the potential effects on existing users of MySQL persistence? If MySQL server and openHAB server times are very different, there will be a time leap in persisted item states in rows inserted after this change is running, which may be unwanted. Perhaps a compatibility flag for openhab.cfg / mysql.cfg, and the code would use the time source the user specified? |
I like the idea of making this user configurable. Beneficial for those who
want to continue to use the server time...
|
Maybe a |
I added flag 'localtime' to configuration and it defaults to 'false'. |
Excellent, thanks @herby3. Could you also update mysql.cfg and also the wiki page (noting in the wiki page that this is a 1.9 enhancement)? With that, and your testing that it works as intended, we should be ready to merge this PR. |
# For new installations, its recommend to set "mysql:localtime=true". | ||
# (optional, defaults to false) | ||
#mysql:localtime=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mysql:
part is not used in mysql.cfg
.
Sry, done! |
Thanks @herby3! |
* master: (178 commits) Fix the generateDeviceId method. (openhab#4498) [modbus] Add support for int32_swap, uint32_swap and float32_swap data types (openhab#4251) Extend error logging on retry failure (openhab#4477) Changed timestamp of item insert from MySql server time to local Java… (openhab#4503) [mochadx10] Add binding to OH2 distro (openhab#4502) [mqtt] Add openhab-action-mqtt feature for OH2 install (openhab#4499) ZWave database update (openhab#4497) Fixes openhab#1003 (openhab#4162) [WeatherBinding] Add log messages for invalid configurations (openhab#4458) Network Health - Made log message more clear (openhab#4425) Update ZMNHSD (openhab#4490) Update clock command class and converter (openhab#4489) Updated modbus config template with serial example. Documented advanced connection parameters (openhab#4487) ZWave update WA105DBZ (openhab#4485) Zwave database 180616 (openhab#4483) Zwave database 180616 (openhab#4479) Add Aeon ZW112 - Door/Window Sensor 6 (openhab#4472) Include Aeon ZW112 - Door/Window Sensor 6 (openhab#4471) Z-Wave: Added support for CENTRAL_SCENE (openhab#4431) ZWave database update (openhab#4476) ... # Conflicts: # bundles/binding/org.openhab.binding.zwave/database/products.xml # bundles/binding/org.openhab.binding.zwave/src/main/java/org/openhab/binding/zwave/internal/converter/ZWaveConverterHandler.java # bundles/binding/org.openhab.binding.zwave/src/main/java/org/openhab/binding/zwave/internal/protocol/commandclass/ZWaveCommandClass.java
see #4495