Convert Java ZonedDateTime to Date - DevDummy

Latest

Views | Thoughts | Concepts | Techniques

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 

1 comment:

  1. On the off chance that they don't have any acquaintance with you well, at that point don't confide in them to pick a date for you.http://znajdzlove.pl/

    ReplyDelete