Re: Help in CalenderAPI



Thanks Wilson...
i read the guideline that are realy help full for writing mails.....

what i was expected was the JD Julian Date as follows

2454043.0417 for 2006Nov03

also let me knw more about how to get the date for proleptic Julian
calendar
i have tried the example as follws but still not get what
expected....so can u plz brief me about it more....

Calendar JCal = new GregorianCalendar();
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz
yyyy G");
//Set date to January 1, 4713 BC
JCal.set(Calendar.YEAR, 4713);
JCal.set(Calendar.DAY_OF_YEAR, GregorianCalendar.BC);
JCal.set(Calendar.ERA, 1);

Date dtJD = JCal.getTime();
System.out.println(dtJD);
System.out.println(sdf.format(dtJD));
System.out.println(dtJD.getTime());
System.out.println(JCal.get(Calendar.ERA));

Date dtToday= new Date();
System.out.println(dtToday.getTime());
System.out.println(dtToday.getTime()-dtJD.getTime());



Ian Wilson wrote:

H2O wrote:
thanks lan,

Please don't top-post!

Ian Wilson wrote:

H2O wrote:

Hi can any one help me out to convert the current date to julian
date using java api??? i have tryied hard for the solution using
GregorianCalender and SimpleDateFormat but still not able to
conver the date to the julian date

i have used the follwing method to do so ...
GregorianCalendar calendar = new GregorianCalendar();

I think you are missing calendar.setTime(new Date());


SimpleDateFormat sdf = new SimpleDateFormat(
"yyyy.MM.dd G 'at' hh:mm:ss z");
Date date = new Date(Long.MAX_VALUE);
System.out.println("Formated date " + sdf.format(date));
calendar.setGregorianChange(date);
Date date1 = calendar.getGregorianChange();

You are getting the Julian-Gregorian transition date which you just
set. What you probably wanted is Date date1 = calendar.getTime();
But Date will give you a Gregorian Date.

System.out.println("Formated date1 " + sdf.format(date1));

Try something like
System.out.println("Julian " + calendar.get(Calendar.YEAR)
+ " " + calendar.get(Calendar.MONTH)
+ " " + calendar.get(Calendar.DATE));


i have tryied your suggesion but it was fail to my exceptions o/p is
Julian 2006 10 2

what i expected was Current Calendar date : 2006 11 1 Julian date for
it : 2454041.0 /// as expected result from julian date converter

The term "Julian Date" has many meanings,
http://en.wikipedia.org/wiki/Julian_Date#Alternatives

From your use of yyyy.MM.dd to format your answer, it looked like you
wanted a Julian Calendar date.

Your new example is of a Julian date of the type commonly used in
Astronomy. You could have saved me from wasting my time by being a bit
clearer to start with :-)

If you read newsgroup posting guidelines you will see that they
generally suggest you provide the values of both the actual output *and*
your expected output.

http://www.yoda.arachsys.com/java/newsgroups.html Item 4 in Java section.


hope will find the solution using jdk but was doubt abt it..because i
found the bug reported in jdk bud database about it...but nowhere
found the solution


Wikipedia says "The Julian day or Julian day number (JDN) is the
(integer) number of days that have elapsed since Monday, January 1, 4713
BC in the proleptic Julian calendar ["

You know how to create a proleptic Julian calendar so create dates for
January 1, 4713 BC and today's date. Subtract the getTime values and
convert from milliseconds to days. Don't forget that Jan 1 was day zero.

.



Relevant Pages

  • Re: Julian date function
    ... according to the algorithm of the Julian calendar ... ... Yes, you are of course correct, the Julian calender uses %4 for leap years, ... whereas the Gregorian uses some extra conditions ... // Routines for processing dates in the format JDN. ...
    (microsoft.public.vc.language)
  • Re: Calendar and Days of the week
    ... Julian calendar, the year is exactly 365.25 days in it, with a leap ... adjust the day to the Gregorian one by taking into account the Julian ... The Julian Day is how astronomers ...
    (sci.math)
  • Re: Help in CalenderAPI
    ... I have found some details about the Julian calendar as follows: ... the cutover date to Long.MAX_VALUE it means GregorianCalendar now have ... To obtain a pure Julian calendar, ...
    (comp.lang.java.programmer)
  • Re: Julian Day Number
    ... I was using the term in an astrophysics context, but I guess shouldn't have assumed everyone would know what I was talking about. ... number on the order of 2,400,000 for dates near the present, potentially including a fractional part for time of day) and go back to a system devised by Julius Scaliger a few centuries ago. ... The "Julian Calendar" of Julius Caesar is unrelated. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Calendar and Days of the week
    ... Classic issue would be to ignore the 100 and 400 year leap rules, ... But that is the point of doing the Julian day first, ... Julian calendar, the year is exactly 365.25 days in it, with a leap ... adjust the day to the Gregorian one by taking into account the Julian ...
    (sci.math)

Loading