Extremely slow parsing of time zone with the new java.time API

As noted in your question and in my comment, ZoneRulesProvider.getAvailableZoneIds() creates a new set of all the available time zones’ string representation (the keys of the static final ConcurrentMap<String, ZoneRulesProvider> ZONES) each time a time zone needs to be parsed.1 Fortunately, a ZoneRulesProvider is an abstract class which is designed to be subclassed. The method … Read more

LocalDateTime.now() has different levels of precision on Windows and Mac machine

The precision is different because LocalDateTime.now() uses a system default Clock. Obtains the current date-time from the system clock in the default time-zone. This will query the system clock in the default time-zone to obtain the current date-time. … The link in this Javadoc takes you to Clock.systemDefaultZone() which states (emphasis mine): Obtains a clock … Read more

Java8 Adding Hours To LocalDateTime Not Working

The documentation of LocalDateTime specifies the instance of LocalDateTime is immutable, for example plusHours public LocalDateTime plusHours(long hours) Returns a copy of this LocalDateTime with the specified number of hours added. This instance is immutable and unaffected by this method call. Parameters: hours – the hours to add, may be negative Returns: a LocalDateTime based … Read more

How to get a java.time object from a java.sql.Timestamp without a JDBC 4.2 driver?

New Methods On Old Classes By using the driver with Java 8 and later, you should automatically pick up some methods on your java.sql.Timestamp object for free. Both java.sql.Time and java.sql.Date have similar conversion methods. Namely, to convert from java.sql to java.time you are looking for: Timestamp::toInstant() Timestamp::toLocalDateTime() Date::toLocalDate() Time::toLocalTime() To go the other direction, … Read more

Which one is recommended: Instant.now().toEpochMilli() or System.currentTimeMillis()

Both are fine. And neither is recommended except for a minority of purposes. What do you need milliseconds since the epoch for? In Java, we can have many different ways to get the current timestamp, For current timestamp just use Instant.now(). No need to convert to milliseconds. Many methods from the first years of Java, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)