How To Get Last 5 Working Days ?

It should take saturday and sunday as non-working days.
I need to take care of month changes also. The preceeding month can be of 30 , 31 or 28 days. We need to take care of year change also. The java Date class doesn't work well , even Calendar abstract class also doesn't do well if month change from
feb to jan , mar to feb , may to apr , jun to may ,aug to jul , nov to oct is required.
if input date given is 5 Feb 2001(calculate last 5 working days)
the output dates should be
5/2/2001
2/2/2001
1/2/2001
31/1/2001
30/1/2001

Here's an exmple:
//last 5 working days
import java.util.*;
class LastFiveWDays{
     public static void main(String [] a){
          boolean done = false;
          int i=0;
          Date date = new Date();
          Date[] lastFive = new Date[5];
          GregorianCalendar cal = new GregorianCalendar();
          while(!done){
               if( cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY ||
                    cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY ){
                         //skip
                         cal.roll(Calendar.DATE, false);
               else{
                    date = cal.getTime();
                    //add to array
                    lastFive[i] = date;
                    cal.roll(Calendar.DATE, false);
                    i++;
               if (i>=5) break;
          print(lastFive);
     public static void print(Date[] arr){
          for (int i=0;i<5;i++){
               System.out.println(arr.toString());

Similar Messages

  • I have a 4s iPhone which I loaded the new Os on last night. Now I can not connect to iTunes. A message comes up saying i need 10.6.3 or later but I am running 10.6.1 as I have an older Mac. Anyone have ideas how to get this to work?

    I have a 4s iPhone which I loaded the new Os on last night. Now I can not connect to iTunes. A message comes up saying i need 10.6.3 or later but I am running 10.6.1 as I have an older Mac. Anyone have ideas how to get this to work?

    Its not telling you to update your iPad, its telling you you need to download a recent version itunes on your computer.
    Go here to download the newest version of iTunes.
    http://www.apple.com/itunes/?cid=OAS-US-DOMAINS-itunes.com

  • How to get last Build date of a dll in the real time target

    Info On My Project    
       I am working on LabWindows CVI 12.0 for development . This project is a real time application for hardware, which is having Phar Lap ETS as RTOS...  
    I am facing some problems while checking Build date of my Application file( .dll)
    I have tried to use GetFileDate API. But it is not supporting for realtime Target..
    So i have tried __DATE__ macro.. That also having some problems..
    How to get last Build date of a dll from the real time target  ??
    Please Help to solve this....
    Thanks
    Vaishakh A  K

    Please reply if any one have suggestion...

  • Showing current date and the last 250 working days

    Hi,
    we need to report the current day and the last 250 working days. How can I implement this into the BEx by using a variable for the current day selection. How can the selection of the last 250 working days work?
    Thanx
    René

    Hi Rene,
    I think that you have to go for a customer exit variable with multiple selections. The exit will calculate all these work days and place them into output for restriction.
    Best regards,
    Eugene

  • How to Calculate the Actuall work days ....

    Hi Friends,
    how to calculate the Actuall Working days Based on the Joining date for 5day work and 6 days work?
    is there any FM to calculate this?
    Thanks in Advance,
    sudha.

    Hi Sudha,
    In your company , If they are maintaining Time Events then you can get the information of Employee's Presense or Absense from infotype 2011 (Time Events) and Absense from 2001 (Absense)..
    Also Consider Factory Calender for it.. and check out working days..
    Table TEVEN
    Try below FM as well..
    HR_DV_TIMEEVENTS_GET
    Hope it will solve your problem..
    Thanks & Regards
    ilesh 24x7
    ilesh Nandaniya

  • How to get last date of the week

    hi,
    how to get last date of the week like FM WEEK_GET_FIRST_DAY gives the date of the first day of the week i need the date of the last day of the week..
    thnx

    data : p_week type KWEEK,
    p_Date type SYDATUM.
    p_week = <incoming value in week of year>
    CALL FUNCTION 'WEEK_GET_FIRST_DAY'
    EXPORTING
    week = p_week
    IMPORTING
    DATE = p_date
    EXCEPTIONS
    WEEK_INVALID = 1
    OTHERS = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    To get the last day of the week.
    p_date = p_date + 6.
    You can find the available fm in the system from se37 transaction code.

  • How to get iMessage to work when all it says is waiting for activation

    How to get iMessage to work when all it says is waiting for activation

    Hi Howell,
    Welcome to Apple Support Communities.
    This article on troubleshooting FaceTime activation has some steps you can try:
    iOS: Troubleshooting FaceTime and iMessage activation
    http://support.apple.com/kb/ts4268
    Have a great day,
    Jeremy

  • Suddenly the apps I downloaded won't work. The screen "blinks" for a second as if the app is loading, and then returns to the home screen. All the apps that came with the iPod seem to be working fine. How to get them all working again?

    Suddenly the apps I downloaded won't work. The screen "blinks" for a second as if the app is loading, and then returns to the home screen. All the apps that came with the iPod seem to be working fine. How to get them all working again?

    First try a hard reset.  To do this, press and hold both the Sleep/Wake and Home buttons together long enough for the Apple logo to appear.
    If still no luck, try downloading another free app from the App Store.
    More troubleshooting here.
    http://support.apple.com/kb/ts1702
    Lastly, try to restore the iPod from a previous backup or restoring it to factory settings.
    B-rock

  • I have purchased itunes match but the cloud will not load on my ipad 4.the only music that will show up is stuff that i bought from the itunes store.any ideas on how to get this to work?

    i have purchased itunes match but the cloud will not load on my ipad 4.it works on my iphone 5 & it originally worked on my ipad.the only music that will show up is stuff that i bought from the itunes store.any ideas on how to get this to work?

    On the MBP, in iTunes, switch to Song view and enable the iCloud Status column by pulling down View > View options and selecting the option for "iCloud Status." Close the small window. Look for any tracks that have a status of "waiting." If you see several of them disable iTunes Match while holding down the Option key. Quit iTunes, wait a few seconds, then open it again and turn iTM back on. Let it compelete the scan. Wait until all tracks that are "waiting" have a status of either "matched" or "uploaded."
    On the iPad, turn off iTunes Match then launch the Music app and let the contents clear out. Power cycle the iPad for good measure, then re-enable the service once all the tracks in iTunes have been processed.

  • When I switch my time capsule to 5.0ghz mode the range of my wireless network drops significantly.  Near the Time Capsule my Macbook Pro works fine, in my bedroom I have almost no signal.  In mixed mode it works fine.  Any ideas on how to get 5.0 working?

    When I switch my time capsule to 5.0ghz mode the range of my wireless network drops significantly.  Near the Time Capsule my Macbook Pro works fine, in my bedroom I have almost no signal.  In mixed mode it works fine both placed.  Any ideas on how to get 5.0 working?  I thought 5.0Ghz was supposed to have a wider range.  Do I need to change a setting on the Macbook Pro?
    Thanks, W

    I'm not sure if you understand that 5 GHz has some upsides, but also some very significant downsides.
    The upside is that the 5 GHz signal will allow faster speeds.
    The downside is that you must always give up something in order to gain something else.Unfortunately, the marketing hype about 5 GHz does not go into very many details about this.
    In the case of 5 GHz, the 5 GHz signals are much weaker than 2.4 GHz signals, so they do not travel as far or penetrate any obstructions like walls or ceilings nearly as well as 2.4 GHz signals. In many cases, in order to get good 5 Ghz performance, you literally have to have almost a line-of-sight relationship between your computer and the wireless router.
    If you have a new dual band router, which broadcasts both a 2.4 GHz and 5 GHz signal simutaneously, your Mac will connect to the best signal quality automatically depending on its location in relation to the router. In the same room, without any obstructions, it will connec to 5 GHz. But, take the laptop down the hall a few rooms and around the corner and the Mac will connect to the 2.4 GHz signal because at that location, the 2.4 GHz signal is not only stronger, it is also faster.

  • ITunes wont open for me. it keeps saying "the Disc "untitled playlist" cannot be read. An unknown error occurred (-69)." don't know how to get it to work. Please help

    iTunes wont open for me. it keeps saying "the Disc "untitled playlist" cannot be read. An unknown error occurred (-69)." don't know how to get it to work. Please help

    It is likely a hardware failure
    http://support.apple.com/kb/TS3694?viewlocale=en_US#error1

  • How to get total number of days

    Hi All,
    how to get total number of days , for example if month eq 05 then need to get total number of days until MAY 31.
    and how to get total number of days in a month.
    Thank You,,
    Sriii..

    Hi Sridhar,
    Pls Try to search before posting general questions.
    Try this,
    CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
        EXPORTING
          i_datum_bis                   = p_lv_date1
          i_datum_von                   = p_lv_date2
       IMPORTING
         e_tage                        = p_e_date_difference
       EXCEPTIONS
         days_method_not_defined       = 1
         OTHERS                        = 2
      IF sy-subrc  0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Regards,
    Sunil kairam.

  • Has anyone figured out how to get speech recognition working with sticky keys enabled on mountain lion?

    I'm trying to use speech recognition to input text on my iMac running the latest mountain lion, 10.8.3.
    I have sticky keys enabled.
    When I try to start speaking by pressing the function key twice nothing happens. I can only get it to work if I disable sticky keys.
    The same problem occurs with all the other modifier keys as shortcut, they do not work with sticky keys.
    When I try to select a different shortcut, I am unable to select a two key combination, but am limited to one.
    If I select the F6 key, or any other single key, I am able to start speech recognition. However the second time that I press the key, it does not stop recognition and process my words. Instead, it restarts the recognition.
    Has anyone figured out how to get speech recognition working with sticky keys enabled?
    Or a way to get an individual key shortcut to start on the first press and process it on the second?
    Or a way to get key combinations to work, as specified by the help:
    Dictation On and Off
    To use Dictation, click On.
    When you’re ready to dictate text, place the insertion point where you want the dictated text to appear and press the Fn (function) key twice. When you see the lighted microphone icon and hear a beep, the microphone is ready for you to speak your text.
    Shortcut
    By default, you press the Fn (Function) key twice to start dictation. If you like, you can choose a different shortcut from the menu.
    To create a shortcut that’s not in the list, choose Customize, and then press the keys you want to use. You can press two or more keys to create your shortcut.

    I noticed with version 10.8.4 of OS X that I am now able to select F6 to activate, and the return key to complete the speech recognition. This is still different than the description of how these should function that's included in the help, but at least it's an improvement.

  • I just got the iphone 4s and i cant figure out how to get siri to work it seems to be the old voice command. HELP!

    i just got the iphone 4s and i cant figure out how to get siri to work it seems to be the old voice command. HELP!

    Did you enable Siri in settings?
    Settings > General > Siri > ON
    If Siri is off, all you get when pressing the home button for 1 second is the old Voice Control.

  • Facebook like button is not working, I have used the muse widget and created code from facebook. Does anyone know how to get this to work?

    Facebook like button is not working, I have used the muse widget and created code from facebook. Does anyone know how to get this to work?

    Hi connally25,
    Below is a link to a video tutorial on how to add a Facebook Log button, please check if you have followed the same steps to add the video.
    http://tv.adobe.com/watch/learn-adobe-muse-cc/adding-a-facebook-like-button/
    If you have followed the steps correctly and the button still does not work; here is a link to a forum thread which might help solving the issue:
    Facebook Follow Widget not working
    Regards
    Sonam

Maybe you are looking for

  • External hard drive seen in Disk Utility, but will not mount.

    My external hard drive has power and is spinning, but will not mount.  It was fine yesterday.  It shows up in Disk Utility and is verified and repaired.  Tried the drive on 2 other macs with same result.  Tried a new enclosure and that did not work. 

  • Master-Detail Event in Obiee 11g

    Hi all, In master report i am using item family. Detail report columns are item family,item name, cost and revenue. Same analysis i created graph and table view. When i am selecting item family in master i am getting correct changes in detail graph b

  • Map with 500 pdfs. How to make a new file with only the first pages, new file with second pages etc.

    Hi, A client confronted me with the next question: I have a map with 500 pdf's in it. Is it possible to make a new file with only the first page of each pdf? After that to make a new file with only the second page of each pdf? And after that the thir

  • Open preview page in same tab

    Hello, when i check my coding with 'view preview in Firefox' , a new tab is opening. How i can make Firefox and other browsers open same tab all the time. thx

  • Urgent updates to a CS3 page

    I have a couple of pages in my CS3 site to which I need to allow a few users to send urgent status updates. In my mind, they will email their updates - but in reality in DW CS3, How do I do this? Helpful suggestions will be so appreciated. JMW