Re: Help in CalenderAPI
- From: "H2O" <mail.tlad@xxxxxxxxx>
- Date: 2 Nov 2006 00:18:33 -0800
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.
.
- Follow-Ups:
- Re: Help in CalenderAPI
- From: Ian Wilson
- Re: Help in CalenderAPI
- From: H2O
- Re: Help in CalenderAPI
- References:
- Help in CalenderAPI
- From: H2O
- Re: Help in CalenderAPI
- From: Ian Wilson
- Help in CalenderAPI
- Prev by Date: Re: completely lost with XSL ...
- Next by Date: Re: Java Future
- Previous by thread: Re: Help in CalenderAPI
- Next by thread: Re: Help in CalenderAPI
- Index(es):
Relevant Pages
|