I am trying to set a server agnostic date time in my database and I believe the best practice to do so is to set a UTC DateTime. My db server is Cassandra and the db driver
If you are using the ThreeTen backport for Android and can't use the newer Date.from(Instant instant)
(which requires minimum of API 26) you can use:
ZonedDateTime zdt = ZonedDateTime.now();
Date date = new Date(zdt.toInstant().toEpochMilli());
or:
Date date = DateTimeUtils.toDate(zdt.toInstant());
Please also read the advice in Basil Bourque's answer