Convert Java ZonedDateTime to Date - DevDummy

Latest

Development Guide for Dummies, Simple Tech Guides, Shared ...

Thursday, August 30, 2018

Convert Java ZonedDateTime to Date


When working with an application that has interactions on multiple regions, it is often required to maintain the time zone specific data with Java ZonedDateTime. In such situations to make comparisons and be consistent, UTC is used as an reference timezone. 


However there are situations that we have to get the Java plain Date instance , the only time component except the zonal information.

ZonedDateTime can be converted to Java Date by converting it to an instance first,


Date date = Date.from(ZonedDateTime.now().toInstant());


Reference 

No comments:

Post a Comment