Problem:
I have got a directory of files, which have a creation date.
What I am trying to reach is to get the value of the creation date day, month and year.
However, I am working with a FileTime.
I was expecting to be able to call a GetMonth method or such.
Unfortunately, this is not possible, does someone know a nice solution to get the day/month/year of a FileTime?
What have I tried:
I have tried to convert this to the Date type. This is possible, but here are the day, month and year methods deprecated.
I have tried to use to get the milliseconds of the FileTime, but this did not feel like a pretty solution.
Final question: How do I get the day, month and year of a FileTime?
Thanks in forward.
FileTime➙Instant➙ZonedDateTimeI'm assuming that you're using Java 8 or later. You must convert the
FileTimeto anInstant. You can then apply aZoneIdto theInstantto get aZonedDateTimeobject for the time zone you want the date in. The below code converts theFileTimeto date in India time.