cancel
Showing results for 
Search instead for 
Did you mean: 

To get date of second sunday in march and first sunday in november of year

Former Member
0 Kudos

Hi all,

i need some java code to get date of second sunday in march and first sunday in november of every year.

this is very urgent

plz help

thanks in advance

jhansi

Accepted Solutions (0)

Answers (3)

Answers (3)

justin_santhanam
Active Contributor
0 Kudos

Jhansi,

Please find the below code. I made the code on assumption each and every time you will get only <b>YEAR</b> as the input.

<b>UDF1 -November Calculation </b>


    int a =Integer.parseInt("2008");
    GregorianCalendar  gc1 = new GregorianCalendar(a,2,1);
    Calendar cal = Calendar.getInstance();
    cal.setTime(gc1.getTime());
    int d= cal.get(Calendar.DAY_OF_WEEK);
    int fin;
    if(d==1)
    {
      fin=1;
    }
    else
    {
    fin = (7-d)+2; 
    }    
  
    String ret_date = a+"-Nov-"+fin;
    return ""+ret_date+""; 
 

<b>UDF2- March Calculation</b>


   int a =Integer.parseInt("2008");
    GregorianCalendar  gc1 = new GregorianCalendar(a,10,1);
    Calendar cal = Calendar.getInstance();
    cal.setTime(gc1.getTime());
    int d= cal.get(Calendar.DAY_OF_WEEK);
    int fin;
    if(d==1)
    {
      fin=8;
    }
    else
    {
    fin = (7-d)+9; 
    }    
    
    String ret_date = a+"-Mar-"+fin;
    return ""+ret_date+""; 
 

raj.

Former Member
0 Kudos
Former Member
0 Kudos

Hi,

Check below links for UDF's.

UDF

http://flickr.com/photos/8764045@N06/

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/be05e290-0201-0010-e997-b6e...

Example 1

http://www.flickr.com/photo_zoom.gne?id=544183191&size=o

http://www.flickr.com/photo_zoom.gne?id=544183195&size=o

http://www.flickr.com/photo_zoom.gne?id=544183225&size=o

http://www.flickr.com/photo_zoom.gne?id=544183233&size=o

Example 2

http://www.flickr.com/photo_zoom.gne?id=545133789&size=o

http://www.flickr.com/photo_zoom.gne?id=545133791&size=o

http://www.flickr.com/photo_zoom.gne?id=545133801&size=o

http://www.flickr.com/photo_zoom.gne?id=545133807&size=o

http://www.flickr.com/photo_zoom.gne?id=545133811&size=o

http://www.flickr.com/photo_zoom.gne?id=545138911&size=o

http://www.flickr.com/photo_zoom.gne?id=545138913&size=o

http://www.flickr.com/photo_zoom.gne?id=545138915&size=o

http://www.flickr.com/photo_zoom.gne?id=545138917&size=o

http://www.flickr.com/photo_zoom.gne?id=545138947&size=o

http://www.flickr.com/photo_zoom.gne?id=545138951&size=o

http://www.flickr.com/photo_zoom.gne?id=545005958&size=o

Example 3

http://www.flickr.com/photo_zoom.gne?id=549186611&size=o

http://www.flickr.com/photo_zoom.gne?id=549186651&size=o

http://java.sun.com/j2se/1.5.0/docs/api/

/people/krishna.moorthyp/blog/2006/07/29/documentation-html-editor-in-xi

/people/sap.user72/blog/2006/02/06/xi-mapping-tool-exports

http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm

http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/content.htm

/people/stefan.grube/blog/2005/12/30/test-user-defined-functions-for-the-xi-graphical-mapping-tool-in-developer-studio

http://help.sap.com/bp_bpmv130/Documentation/Operation/MappingXI30.pdf

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/d046c490-0201-0010-84b6-9df523cb...

Regards,

Phani

Reward Points if Helpful

bhavesh_kantilal
Active Contributor
0 Kudos

lol..

ravi_raman2
Active Contributor
0 Kudos

Jhansi,

This should help..

public static String date() {

Calendar c = Calendar.getInstance();

String dtl = "" + c.get(Calendar.YEAR) + "_" +

(c.get(Calendar.MONTH) + 1)+ "_" +

c.get(Calendar.DATE) + "_" +

c.get(Calendar.HOUR) + "_" +

c.get(Calendar.MINUTE) + "_" +

c.get(Calendar.SECOND);

System.out.println(dtl);

return dtl;

}

this will return a formatted current ..date..if you are looking for a specific date...this is what i suggest, retrieve the date and check to make sure it is the second sunday in march..so set a boolean variable here..and if true then return the date...

Regards

Ravi Raman