javadatetimetimezonefileinfo

Get created datetime Timezone from properties of a file in Java


I want to convert created DateTime timezone of a file to another timezone. Let's say the created DateTime timezone of a file is "America/Detroit" and I want to convert it into "Atlantic/Bermuda". I could get the created DateTime of a file from its properties with Apache Tika, but in order to convert it to the desired timezone, I need to know the timezone of the created DateTime and I could not get see or get any property as Timezone from the file. I already wrote the conversion code in JAVA with DateTime and Timezone as Input.

So is there a way by which I could get the created DateTime Timezone of a file with Java?


Solution

  • When You right-click the file and view the properties, the Timezone of the created DateTime present there is actually your system Timezone. Now, When you apply Apache Tika to get the properties of the file, It would give the UTC format of the DateTime irrespective of your system Timezone.

    So to achieve the desired output from the code/function, Give the DateTime as given by apache Tika and give the Timezone as UTC and convert it to some Timezone of your choice.