Re: Help in CalenderAPI
- From: "H2O" <mail.tlad@xxxxxxxxx>
- Date: 3 Nov 2006 01:47:08 -0800
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.
.
- Follow-Ups:
- Re: Help in CalenderAPI
- From: Ian Wilson
- Re: Help in CalenderAPI
- References:
- Help in CalenderAPI
- From: H2O
- Re: Help in CalenderAPI
- From: Ian Wilson
- Re: Help in CalenderAPI
- From: H2O
- Re: Help in CalenderAPI
- From: Ian Wilson
- Help in CalenderAPI
- Prev by Date: Re: Is there any one who has been working with java for a long long time?
- Next by Date: Re: pass-by-reference
- Previous by thread: Re: Help in CalenderAPI
- Next by thread: Re: Help in CalenderAPI
- Index(es):
Relevant Pages
|
Loading