Re: Help in CalenderAPI



thanks lan,
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

for more information about julian date
http://www.aavso.org/observing/aids/jdcalendar.shtml

cureent julian year is 245 and julian day is 4041
the date i m geting using the getGregorianChange is no where same as
julian day or julian year...i was strugling to get it using pure java
api...there are many third party api which i can use but client requied
and trust on jdk only....and as mention on jdk doc the
GregorianCalender need to act as pure julian calender if it for it
using newDate(Long.MaxValue)

even i tryied using simple date format to format the date i get from
getGregorianChange
and date.getTime() but fail to foamt as per the julian astronomy foamat

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


Api Desc :
setGregorianChange
public void setGregorianChange(Date date)Sets the GregorianCalendar
change date. This is the point when the switch from Julian dates to
Gregorian dates occurred. Default is October 15, 1582. Previous to
this, dates will be in the Julian calendar.
To obtain a pure Julian calendar, set the change date to
Date(Long.MAX_VALUE). To obtain a pure Gregorian calendar, set the
change date to Date(Long.MIN_VALUE).


Parameters:
date - the given Gregorian cutover date.





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));



}

but not geting the current date so if any one knw about the same then
plz let me knw ASAP


I find newsgroups are good if you can wait a day or so for solutions.

.



Relevant Pages

  • Re: Happy Newtonmas!
    ... days of the Julian Calendar, so when they switched to Gregorian, they ... The Julian and Gregorian calendars were in sync in the *3rd* ... In the 1st century the Julian calendar was two days *ahead* so ...
    (rec.music.classical.recordings)
  • 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: Unix Time Format to VB5 as string and / or Date Format
    ... I wrote a QBasic program to interconvert Gregorian dates ... The algorithm it uses to convert Julian Days to Gregorian dates ... DECLARE SUB J2G ... ' Calendar cycle lengths are handled successively, ...
    (comp.lang.basic.misc)
  • Julian Day converter
    ... ' Julian Day and Gregorian Date interconverter ... Date must be after adoption of Gregorian Calendar, ... DECLARE SUB J2G ... ' Utility function used by JultoGreg ...
    (comp.lang.basic.misc)
  • Re: Happy Newtonmas!
    ... days of the Julian Calendar, so when they switched to Gregorian, they ... In the 1st century the Julian calendar was two days *ahead* so ... significantly shift in the course of 10 or 20 years? ...
    (rec.music.classical.recordings)