从Java中的文件的属性中创建DateTime时区

发布于 2025-02-05 06:20:24 字数 248 浏览 2 评论 0原文

我想将文件的DateTime TimeZone转换为另一个时区。假设文件中创建的DateTime时区为“美国/底特律”,我想将其转换为“大西洋/百慕大”。 我可以通过Apache tika从其属性中获取文件的创建日期时间,但是要将其转换为所需的时区,我需要知道创建的日期时间的时区,我无法从中看到或从中获得任何属性,文件。我已经在Java中以DateTime和TimeZone作为输入编写了转换代码。

那么,有没有办法使用Java获得文件的创建的DateTime时区?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

满身野味 2025-02-12 06:20:24

当您右键单击文件并查看属性时,存在的DateTime的时区实际上是您的System TimeZone。现在,当您应用Apache Tika以获取文件的属性时,无论您的System TigeZone如何,它都会给出DateTime的UTC格式。

因此,为了实现代码/功能的所需输出,请给出Apache Tika给出的DateTime,并将TimeZone作为UTC提供,然后将其转换为您选择的某些时区。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文