Skip to Content
author's profile photo Former Member
Former Member

Julian Date and Day

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Apr 27, 2012 at 03:45 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 29, 2012 at 01:20 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 27, 2012 at 03:30 PM

    I don't think standard date functions support julian date. You might have to write UDF to implement this.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Apr 27, 2012 at 03:41 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.