on 04-27-2012 4:05 PM
Hi,
I need my filename to be created based on Julian Date or Julian Day. I have a field in mapping which can be used for this.
I am struggling whether the currentdate function offers Julian Date or Day.
Please let me know if any one has done a requirement like that.
Regards
Anandh.B
Hi,
This can be done with the following UDF:
Calendar calendar1 = Calendar.getInstance();
Calendar calendar2 = Calendar.getInstance();
calendar1.set(1, 0, 1); //leave this unchanged
calendar2.set(2012, 3, 27); //put your input date's year, month-1 (0 to 11 instaed of 1-12) and day
long milliseconds1 = calendar1.getTimeInMillis();
long milliseconds2 = calendar2.getTimeInMillis();
long diff = milliseconds2 - milliseconds1;
long diffDays = diff / (24 * 60 * 60 * 1000);
diffDays += 1721423;
return diffDays;
Hope this helps,
Greg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anandh.B,
The Julian date (JD) is the interval of time in days and fractions of a day since January 1, 4713 BC Greenwich noon, Julian proleptic calendar. The Julian day number (JDN) is the integer part of the Julian date (JD).The day commencing at the above-mentioned epoch is JDN 0. Now, at 12:39, Sunday April 29, 2012 (UTC) the Julian day number is 2456047. Negative values can be used for dates preceding JD 0, though they predate all recorded history. However, in this case, the JDN is the greatest integer not greater than the Julian date rather than simply the integer part of the JD. Please consult this link for formula to obtain julian date
http://scienceworld.wolfram.com/astronomy/JulianDate.html
and the following to test the output of UDF shown below
http://aa.usno.navy.mil/data/docs/JulianDate.php
the UDF is as shown below
public String currentDateToJulianDate(Container container){
String julianDate="";
try
{
java.util.Calendar cal = new java.util.GregorianCalendar();
double hour24 = cal.get(java.util.Calendar.HOUR_OF_DAY); // 0..23
double min = cal.get(java.util.Calendar.MINUTE); //0..59
double sec=cal.get(java.util.Calendar.SECOND);
int day=cal.get(java.util.Calendar.DAY_OF_MONTH);
int month=cal.get(java.util.Calendar.MONTH)+1;
int year=cal.get(java.util.Calendar.YEAR);
double jd=0.0;
jd=(367*year)-(int)(7*(year+(int)((month+9)/12))/4)
-(int)((3*(int)((year+(month-9)/7)/100)+1)/4)
+ (int)((275*month)/9)+day+1721028.5
+(hour24+(min/60)+(sec/3600))/24;
julianDate=""+jd;
}
catch(Exception e)
{
e.printStackTrace();
}
return julianDate;
}
This UDF converts current date and time to julian date.
Hope this resolves your problem.
Regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI AnandhaKrishnan,
I agree with Baskar.you should create an UDF to resolve this problem. Check this web with an example in java http://www.rgagnon.com/javadetails/java-0506.html
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't think standard date functions support julian date. You might have to write UDF to implement this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.