朱利安日期到定期日期转换 [英] Julian date to regular date conversion

查看:1185
本文介绍了朱利安日期到定期日期转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用java API将代表2013年11月18日的julian日期2456606转换为18/11/2013的字符串格式?我尝试执行下面的代码,但它没有给我正确的答案。欢迎对以下代码进行任何更正。

How do i convert a julian date 2456606 which stands for Nov 18 2013 to the string format 18/11/2013 using java APIs? I tried executing the below code but it is not giving me the right answer. Any corrections to the below code are welcome

    String j = "2456606";
    Date date = new SimpleDateFormat("yyyyD").parse(j);
    String g = new SimpleDateFormat("dd.MM.yyyy").format(date);
    System.out.println(g);


推荐答案

2013年11月18日的Julian日期为2013322。您使用的号码2456606将是2456年第606天,即2457年8月28日。

The Julian date for Nov 18 2013 is "2013322". The number you used, "2456606", would be the 606th day of 2456, which is Aug 28, 2457.

您可能还有意图使用与yyyyD不同的日期格式。请参阅 http://docs.oracle.com/javase/ 6 / docs / api / java / text / SimpleDateFormat.html ,以获取有关可能代码的信息。

You might also have intended to use a different date format than "yyyyD" for your input. See http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html for information on possible codes.

修改

用于儒略日期的价值是公元前4713年1月1日以后的天数。要获得使用该系统的Julian日期,您需要执行以下操作:

The value that you used for the Julian date is the number of days since January 1, 4713 BCE. To get the Julian date using that system, you'll need to do something like the following:

String j = "2456606";
int day = Integer.parseInt(j) - x; // x == Jan 1, 1970 on the Gregorian
j = Integer.toString(day);
Date date = new SimpleDateFormat("D").parse(j);
String g = new SimpleDateFormat("dd.MM.yyyy").format(date);
System.out.println(g);

其中 x 是对应于1970年1月1日,公历,即从公元前4713年1月1日到1970年1月1日之间所经过的天数。

Where x is the Julian day corresponding to Jan 1, 1970 on the Gregorian calendar, i.e., the number of days elapsed between January 1, 4713 BCE and Jan 1, 1970.

这篇关于朱利安日期到定期日期转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆