How to identify which is current week by java.util.Date

below code wriiten to identify number of weeks in a given month,
i need current week in a from below code.Can any one help me?
for(int i=1;i<32;i++){
Date d = new Date(2005,11,i);
intMonDtTemp=d.getMonth();
0-sunday
1-monday
5-friday
6-saturaday
// number of weeks is based on monday's in given month
//System.out.println(intMonDtTemp+" at =month dt "+ intMonDt);
if(intMonDtTemp==intMonDt){
     //System.out.println(i+" = "+ d);
     //System.out.println("MONTHS EQUAL");
     if(d.getDay()==1){
          count= count+1;
}//end of for
if(count==5){
     System.out.println(strDt+" = 5 weeks");
} else {
     System.out.println(strDt+" = 4 weeks");
}//end of else

using Calendar, not Date
import java.util.Calendar;
class Testing
  public Testing()
    Calendar cal = Calendar.getInstance();
    int month = Calendar.OCTOBER;// months are 0-based 0-11, not 1-12
    cal.set(2005,month,1);
    int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
    if(dayOfWeek > 2) dayOfWeek -= 7;
    cal.add(Calendar.DATE,2 - dayOfWeek);
    int mondaysInMonth = 0;
    while(cal.get(Calendar.MONTH) == month)
      cal.add(Calendar.DATE,7);
      mondaysInMonth++;
    System.out.println("Mondays in month = "+mondaysInMonth);
  public static void main(String[] args){new Testing();}
}

Similar Messages

  • How i convert string(dd/mm/yyyy) to java.util.Date object

    <%
       try{
             String date="1/8/2000";
             SimpleDateFormat ts= new SimpleDateFormat("dd-MMM-yyyy");
             Date  sqlToday = new java.sql.Date(ts.parse(date).getTime());
            out.println("I am Here");
             out.println("Date:"+sqlToday);
            out.println("After Date:");
             catch(ParseException e){
                  e.printStackTrace();
      %>It is the code and i cann't get any result.
    i am very new to JSTL and netbeans pls help me
    Thanks in Advance

    Write your format string to match the user input. ie yyyy-MM-dd (if that is what the user types in). MMM means month in short words - ie Jan, Feb, Mar etc
    Once you parse it into a date, and get a java.sql.Date, you should use a prepared statement and the setDate() method.
    Try
    dd/MM

  • How to identify which applicarion is using the DVD burner?

    How to identify which applicarion is using the DVD burner? Ot is not allow me to burn the DVDs genetrated in the Final Cut 7

    I think you'll find that the application is Final Cut Pro...  the message is bug.  I get a similar message when disconnecting external drives after using them with FCP (even when the project is no longer loaded.)
    As I mentioned above, the accepted workflow is to export the sequence to one of your hard drives using the Export>QuickTime Movie path with Settings:Current Settings and Make Movie Self-Contained checked like this:
    This gets you a high quality "master copy" which you open in Compressor for transcoding. You should use the DVD: Best Quality setting for the duration of your movie.
    this gets you the high quality MPEG-2 and AC-3 files for DVD Studio Pro authoring.
    If you've never used DVD Studio Pro before, you can use iDVD instead. For iDVD, you just drag and drop your "master" on iDVD and it takes it from there. Both make a very professional product.
    hope this helps.

  • How to identify which is rootsite/webapplication url and which are site collection url ?

    How to identify which is rootsite/webapplication url and which are site collection url underneath of web application using powershell script in following code?
    # Get site objects
    $webapplication = Get-SPWebApplication $siteUrl
    # Walk through each site in the site collection
    foreach($site in $webapplication.Sites)
    foreach($subWeb in $site.AllWebs)
    $_ = AddLevel123($subWeb.Url)

    Hi,
    Hope you wanted to know which API is Site collection (SPSite) and Sub site(SPWeb) 
    $webapplication.Sites = Site Collection (SPSite)
    and $site.AllWebs = Subsite (SPWeb)
    and see these links - to get webApplication URL
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/e223b607-ab35-454a-a050-1db3005687e5/spwebapplication-url?forum=sharepointdevelopmentlegacy
    SPSite Url - SPSite.Url (http://msdn.microsoft.com/en-us/library/office/microsoft.sharepoint.spsite.url.aspx)
    SPweb URl - SPWeb.URL (http://msdn.microsoft.com/en-us/library/office/microsoft.sharepoint.spweb.url.aspx)
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/b4dfb645-69f4-4abd-947c-64ca42af3a26/script-to-get-list-of-sites-and-subsites
    Hope this helps!
    MCITP: SharePoint 2010 Administrator
    MCTS - MOSS 2007 Configuring, .NET 2.0
    | SharePoint Architect | Evangelist |
    http://www.sharepointdeveloper.in/
    http://ramakrishnaraja.blogspot.com/

  • How to identify which videos

    I took a dozen or so short clips of an event. I know which three I want to combine and edit. But I can't figure out how to identify which they are in imovie in order to put those clips in my project. It shows them all as consecutive clips or frames, without file numbers or names.

    I'll try to explain better.
    A dozen clips or videos, 1 min to 5 min in length. In one case all along a mountain road.
    I want to produce a 5 min project or video with the best parts of 3 of those 12.
    All 12 have thumbnails almost identical (the dashboard across the bottom, roof line at the top)
    I only want to start editing the 3, not put all 12 in.
    How do I identify those 3?

  • How to identify Which function modules are used in the planning area?

    Hi all,
    there are couple of function module derviation is used to derive the calendar year, month, fiscal period etc.
    But how to identify which function module is used in which planning area?
    I cant find out from the where used list from function modules?
    Thanks
    pooja

    Hi Pooja,
    Go to characteristic relationship tab,click on detail icon on extreme left of the derivation,there you will get the name and the details of function module used for derivation.
    Regards,
    Indu

  • How to identify Which ports are using in RAC setup?

    Hi,
    how to identify Which ports are using in RAC setup?
    Thnaks,

    [Viewing Port Numbers and Access URLS|http://download.oracle.com/docs/cd/B19306_01/install.102/b14205/ports.htm#sthref1208]

  • How to identify which DC to modify?

    I need to change the iView u201CChange Own Datau201D in ESS.
    ESS -> Employee search -> Change Own Data
    How to identify which DCs to modify in development configuration?
    Greatly appreciated for any comment/suggestion!

    Hi,
           The purpose of each DC is modifying different Iviews (Ex:you need to modify Change Own data like that some other needs to change some other Iview may be this Iview will be present in another DC).
    based on our requirement we need to modify different different DCs.
    yes you need to modify in the DC as i mentioned..
    Regards,
    Anil.

  • How to identify which key figure will the numeric pointer for deltas?

    Hi All,
    I have created a numeric pointer for generic extraction ? but how to identify which key figure will the numeric pointer will use for deltas ?
    how to identify the key figures which is suitable for numeric pointer. And the generic extraction is based upon the copa table?
    Can anyone suggest me how the numeric pointer works and how to identify deltas are carried out at numeric pointer?
    Thanks
    Pooja

    Pooja,
    If you are using a generic extractor which is based on COPA table, then numeric pointer may not be the suggested delta extraction mechanism. 
    A time stamp would be the better one to use.  In a time stamp, you can give a lower limit value of 300 seconds.. so that it will try to fetch the missed records.
    Moreover, a delta would be based on a character, preferably a time char.
    In your requirement, try to figure out the character on whichdeltas will be based.
    Sasi

  • How to identify which record(s) the user hasbeen checked

    i have a internal table in which first field is represented as check box in the output .
    like bellow
      loop at g_it_final into g_wa_final.
            write : 5 sy-tabix ,
                   20 g_wa_final-g_v_check as checkbox,
                   25 g_wa_final-TRKORR,
                   40 g_wa_final-AS4TEXT.
      endloop.
    now the user will select some records from the output checking the check box
    NOW the QUESTION is
    how to identify which record(s) the user hasbeen checked(selected) ?
    so that i can disply only the selected records in the secondary list.

    Hi,
    You will have to use the 'READ LINE' command within a loop to retrieve the data back into your program.
    You may want to use the HIDE command to ease the retrieval of the checkbox value.
    Check out the online help for both of these.
    Darren

  • How to identify which Internal order type is relevant for Budget manager

    Hi,
        How to identify which Internal order type is relevant for Budgeting i.e Budget Manager.
    regards,
    Rajesh

    controlling-internal orders-budegeting and availability control -define tolerance limits for availabilty control
       in which it is defined whether mail be sent to budget manager against the budget profile(budget profile is assigned to order type).
    controlling-internal orders-budegeting and availability control -define tolerance limits for availabilty control-maintain budget manager
    here budget manager is assigned to  order type
    assign me points if it is useful

  • How to identify which root certificate is used?

    How to identify which root certificate(on terminal) is used when a terminal is connecting to a https website?
    SecurityInfo.getServerCertificate() only returns the certificate send from the https server.
    But how could know the which local root certificate is used to verify the certificate send from the https server?
    Is there a method or class in MIDP 2.1?
    Thanks

    UP�Cthis question is urgent. Hope anyone can answer me!

  • How can i compare:  java.util.Date oracle.jbo.domain.Date?

    I have made a ViewObject wich contains a date column.
    I want to check if this date is smaller/greater than sysdate:
    i get following error:
    Error(45,24): method <(java.util.Date, oracle.jbo.domain.Date) not found in class Class4
    code:
    SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
    // set up rules for daylight savings time
    pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
    pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
    // create a GregorianCalendar with the Pacific Daylight time zone
    // and the current date and time
    Calendar calendar = new GregorianCalendar(pdt);
    Date trialTime = new Date();
    calendar.setTime(trialTime);
    (VO_ULNRow)singleRow = null;
    while(vo.hasNext()){                                             // ViewObject vo;
    singleRow = (VO_ULNRow)vo.next();
    if(calendar.getTime() < singleRow.getEO_ULN_BORROWFROM()); //singleRow returns oracle.jbo.domain.Date
    etcetera
    how can i compare those 2?

    Hi,
    oracle.jbo.domain.Date has two methods which suit your needs
    longValue() which returns a long (though I'm not sure if returns a long comparable to the long returned by java.util.Date)
    and dateValue() which returns a java.util.Date
    I hope it helps,
    Giovanni

  • This tex.setValue(new java.util.Date().toString()); no give me current time

    hi master
    sir i use this textfield1ddt.setValue(new java.util.Date().toString()); command for current date and time
    first time when i press button this command give me this 
    Sat Sep 08 14:07:05 GMT+05:00 2007
    result in my textbox  but again i press press button no change in textfield
    and not give me current time
    please give idea how i give current time
    thank's
    aamir

    Hi!
    You can use GregorianCalendar.getInstance().getTime() which returns current data as instance of Date class for default time zone and locale.
    Thanks,
    Roman.

  • Java.util.Date oracle.jbo.domain.Date how can i compare?

    I have made a ViewObject wich contains a date column.
    I want to check if this date is smaller/greater than sysdate:
    i get following error:
    Error(45,24): method <(java.util.Date, oracle.jbo.domain.Date) not found in class Class4
    code:
    SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]);
    // set up rules for daylight savings time
    pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
    pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000);
    // create a GregorianCalendar with the Pacific Daylight time zone
    // and the current date and time
    Calendar calendar = new GregorianCalendar(pdt);
    Date trialTime = new Date();
    calendar.setTime(trialTime);
    (VO_ULNRow)singleRow = null;
    while(vo.hasNext()){ // ViewObject vo;
    singleRow = (VO_ULNRow)vo.next();
    if(calendar.getTime() < singleRow.getEO_ULN_BORROWFROM()); //singleRow returns oracle.jbo.domain.Date
    etcetera
    how can i compare those 2?

    i get following error:
    Error(45,24): method <(java.util.Date,
    oracle.jbo.domain.Date) not found in class Class4
    if(calendar.getTime() <
    singleRow.getEO_ULN_BORROWFROM()); //singleRow returns
    oracle.jbo.domain.Date
    how can i compare those 2? You cannot compare these two values directly. You must convert the oracle.jbo.domain.Date object to a GregorianCalendar object. Something like:
      oracle.jbo.domain.Date dt = singleRow.getEO_ULN_BORROWFROM();
      GregorianCalendar gc = new GregorianCalendar(dt.getYear(), dt.getMonth(), dt.getDay());
      if (calendar.getTime() < gc.getTime())
      }

Maybe you are looking for

  • Memory upgrade not working

    I ordered 8GB memory for my imac mid-2011 model. I then tried to install and all I'm getting is three beeps telling me there's something wrong with my memory. I've tried all configurations but can't get the 2x4gb modules to work. I've had to stay wit

  • Save As Reference Movies for More than 1 file

    Hi, Okay, so I have like 25 AVI/MPG files that I want to save as MOV Referenced Files using Quicktime Pro. I know, I can do by opening 1 at a time and using Save As Option. However, the question is; Is there a script or automated way to do for all th

  • Acrobat 9 Pro and LiveCycle

    I have Acrobat 9 pro now and for some reason it won't show up in the preview window in LC now. Do you know why?

  • Sound Vanishes When Moving Clip From Clips Pane To Video Selection Timeline

    Hi, I've been using iMovie for years and never run into a problem, but just today I imported some video, played it back fine in the clips pane, then dragged them down into the main video timeline, and all of a sudden there's no sound on them. The vid

  • Adding elements to a node: cannot bind or add element

    Hallo, I want add emenents of my phases and subphases to a table, but I get this exception: ContextException: Node(RoadMapVIew.phase_subphase_table): cannot bind or add element, because it is already bound to a node The code is the following: int pha