How to pass from method to arguments to main and get the day of the week

Hi
Need some help, this code below doesnt fit the requirement.
For this program, i need to: take in day, month,year of a date as int argument, return the day of the week for the date entered in App()
In Main: call the App() to get the day of the week to display when user enter the date in dd/mm/yyyy
StringTokenizer is required for this program.
- How can the arguments pass back to main by returning of month & day of the week?
- Program cant take in int and return as string
- Date cant display day of the week
Code
import java.util.*;
public class App2 {
    private int day;
    private int month;
    private int year;
         private int inputDay;
            private int inputMonth;
            private int inputYear;
    public static String App2(String day2, String month2, String year2) { // this is wrong should pass int in
          String date = day2 + month2 + year2;
         DateFormat df = new SimpleDateFormat("dd/MM/yyyy");  
          try
          Date today = df.parse(date);               
          System.out.println("Today = " + df.format(today));
          catch(ParseException e)
          if(month2.equals("01") || month2.equals("1")){month2 = "January";}              
          else if(month2.equals("02") || month2.equals("2")){month2 = "February";}              
          else if(month2.equals("03") || month2.equals("3")){month2 = "March";}              
          else if(month2.equals("04") || month2.equals("4")){month2 = "April";}              
          else if(month2.equals("05") || month2.equals("5")){month2 = "May";}              
          else if(month2.equals("06") || month2.equals("6")){month2 = "June";}              
          else if(month2.equals("07") || month2.equals("7")){month2 = "July";}              
          else if(month2.equals("08") || month2.equals("8")){month2 = "August";}              
          else if(month2.equals("09") || month2.equals("9")){month2 = "September";}              
          else if(month2.equals("10")){month2 = "October";}              
          else if(month2.equals("11")){month2 = "November";}              
          else if(month2.equals("12")){month2 = "December";}
          return month2;
    public static void main (String [ ] args){
         Scanner sc = new Scanner(System.in);
            System.out.print("Enter the date in dd/mm/yyyy: ");
            String date = sc.nextLine();
            StringTokenizer st = new StringTokenizer(date, "/");
            String day = st.nextToken();
            String month = st.nextToken();
            String year = st.nextToken();
            App2(day, month, year);
            String test = App2(day, month, year);
                 System.out.print(test);
}Program output: 29 Aug 2010 is a Sunday

Note: This thread was originally posted in the [Java Programming|http://forums.sun.com/forum.jspa?forumID=31] forum, but moved to this forum for closer topic alignment.

Similar Messages

  • How to invoke adobe life cycle webservice using c++ (how to pass blob structure as argument)

    We already wrote sample code (.NET C#) to access livecycle webservice(this convert the input file into pdf file) using below link from adobe
    http://livedocs.adobe.com/livecycle/8.2/programLC/programmer/help/wwhelp/wwhimpl/common/ht ml/wwhelp.htm?context=sdkHelp&file=000088.html
    We want to write c++ client to invoke adobe life cycle webservice. I have sample code to invoke the given webservice using plain c++ but I am stuck up with 'how to pass BLOB structure as argument to CreatePDF() method' and
    plus 'how to get ouput as mapItem[]' . Is the code to convert to pdf works fine with .NET and java only? Not with c++ or VB?

    In this case the LiveCycle services are exposed as web services that can be consumed by any application language that can interact with web services. While the sample published are for c# and Java there is no reason that other web service aware languages (C++, Perl, etc) wouldn't work.
    I'm not a Microsoft C++ expert, but as far as I understand all you need to do is create a web reference and then have your C++ classes interact via the generated proxy classes. The syntax will be different, but the concept is the same

  • How to pass from a document pdf towards another

    Hello,
    I have two open documents.
    In javascript, how to pass from a document pdf towards another.
    David G

    You need to mark each document as "disclosed", in order for them to talk to each other. See the Acrobat JavaScript docs on "this.disclosed".
    Leonard

  • How can i say yes to automatic updates when they stop my wireless dlink to Virgin home broadband from getting on the internet and then i have to do a system restore to the day before the update to get it back to normal?!? Frustrated

    how can i say yes to automatic updates when they stop my wireless dlink to Virgin home broadband from getting on the internet and then i have to do a system restore to the day before the update to get it back to normal?!? Frustrated
    == This happened ==
    Not sure how often
    == automatic updates go on my computer, say if i click yes to update when shutting down

    You have 10.6 on that machine, I suggest you stick with it for performance, third party hardware and software reasons as long as possible.
    Consider 10.8 (not 10.7) when it's released, because 10.7 and 10.8 will require a new investment in software and newer third party hardware as it requires newer drivers the old machines won't have. (forced upgrade because of software, really nice of them)
    http://roaringapps.com/apps:table
    Far as your Safari problem do these things until it's resolved:
    1: Software Update fully under the Apple menu.
    2: Check the status of your plug-ins and update (works for all browsers) also install Firefox and see if your problems continue. You should always have at least two browsers on the machine just in case one fails.
    https://www.mozilla.org/en-US/plugincheck/
    Flash install instructions/problem resolution here if you need it.
    How to install Flash, fix problems
    3: Install Safari again from Apple's web site
    https://www.apple.com/safari/
    4: Run through this list of fixes, stopping with #16 and report back before doing #17
    Step by Step to fix your Mac

  • Hi, I downloaded get tube from google on my i mac and now want to delete the app completely, how can I do so?

    Hi, I downloaded get tube from google on my i mac and now want to delete the app completely, how can I do so?

    Get AppZapper, a free program that removes apps.  Make sure everything has been removed by checking with Spotlight once the app has been zapped.

  • I'm trying to submit a document from pages to a URL address and it keeps giving me the option to load pictures or take a new picture, how do I change this?

    I'm trying to submit a document from pages to a URL address and it keeps giving me the option to load pictures or take a new picture, how do I change this?

    If mean by way of Safari, that is correct. Only content of the Camera or Photos apps are available. you will need to find an alternate app such as iCab Mobile for uploading documents to a website.

  • Im switching email accounts on my itunes account am the computer isnt recognizing purchases made from my other account on the new one (apps). How can I sign in with my new account and get the purchases apps on both accounts?

    Im switching email accounts on my itunes account am the computer isnt recognizing purchases made from my other account on the new one (apps). How can I sign in with my new account and get the purchases apps on both accounts?

    This was EXACTLY what I needed about the purchases I made from my device. However, is there a way to re-download other ones you've made from a computer? Because I realized some of them were not just purchased from my device.
    This is a picture of what it looks like now:
    http://tinypic.com/r/107quxu/7
    As you can see, the stuff circled in red doesn't give me an option to download from Cloud Beta because it already says "downloaded".
    any way to get around that?

  • TS1424 i have purchiced a cd from the ituns store but it seems to keep downloading how do i stop this and get a refund for the extra cd

    I have downloaded a CD from the itunes store but it seems to keep downloading. how do i stop this and get a refund for the unwanted CD's

    Welcome to the Apple Community.
    Try deleting the problematic file (electing to remove original file if/when prompted) and then re-downloading the file from the iTunes store.
    You can re-download content purchased from the iTunes store (availability varies depending on location) using the purchased option from the Quick Links section in the top right corner of the iTunes homepage in your iTunes application on your computer.
    You can re-download content purchased from the iTunes store (availability varies depending on location) using the purchased option at the bottom of the screen of the iTunes app (or video app) on your iOS device.
    If the problem re-occurs, select the content which is causing a problem and use the 'Report a problem' button in Your Purchase History using your computer.

  • Function Module to get first day of the fiscal year on passing a date

    Hi Experts!!
    Can you please suggest a Function Module to get first day of the fiscal year on passing a date..?
    Example:  if a fiscal year starts from 30 November 2009 and ends at 28 november 2010.
    it should return 30 th nov 2009 (first day of the fiscal year)

    Moderator message - Welcome to SCN.
    I think you'll find that this question has been answered before. Please search the forum before posting.
    Also, Please read Please read "The Forum Rules of Engagement" before posting!  HOT NEWS!! and How to post code in SCN, and some things NOT to do... and [Asking Good Questions in the Forums to get Good Answers|/people/rob.burbank/blog/2010/05/12/asking-good-questions-in-the-forums-to-get-good-answers] before posting again.
    Rob

  • HT201318 How do I downgrade my iCloud storage and get a refund within the 15 days?

    Help!
    How do I downgrade my iCloud storage and get a refund within the 15 days?
    I recently up-graded from 10 to 20GB in the middle of my storage plan, but I've changed my mind. How can I get a refund and revert my account back to its previous settings?

    If in the US, follow the link below (you must request a refund within 15 days) -
    https://discussions.apple.com/message/16968425#16968425
    it gives the USA phone number - if you don't live there you will have to find an equivalent number from the 'Contact Us' link at bottom right of this page.

  • How to get previous day of the date

    Hi,
    for a given date I need one day minus as a result date
    my input would be any date
    for example :
    Input Date : 2006-03-22 ( yyyy-mm-dd)
    Output should be : 2006-03-21
    If my input is 1st of April 2006, output i would expect is 31st March 2006
    Please suggest how to achieve this
    Thanks in advance
    Nilesh

    Find below the code to get previous day of the current date
    import java.util.Date;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    public class PreviosDay
    public static void main(String[] args)
    DateFormat dateFormat = new SimpleDateFormat( "MM/dd/yyyy");
    Calendar cl = Calendar.getInstance();
    // you can use a Date object's getTime() method , which is initialiazed
    // to desired date here directly ex: Date dt = new Date("10/10/2004");
    // cl.setTimeInMillis(dt.getTime());
    cl .setTimeInMillis(System.currentTimeMillis());
    cl.add(Calendar.DAY_OF_MONTH, -1);
    System.out.println("Previous date : "+dateFormat.format(
    new Date(cl.getTimeInMillis() ) ) );
    }

  • I'm told there is a virus associated with Adobe Reader. How can I tell if my machine is effected and if so what is the cure. I'm running OS X10.6.8 on an iMac with safari 5.1.5

    I'm told there is a virus associated with Adobe Reader. How can I tell if my machine is effected and if so what is the cure. I'm running OS X10.6.8 on an iMac with safari 5.1.5

    There are no viruses currently affecting the Mac but there is something called Flashback which is malware that has been doing the rounds and affected many Mac users. Apple have released some updates to Java that should remove it and improve protection. Run Software Update to see if there is anything for downloading.
    A few precautions that can help prevent your Mac becoming infected:
    If you use Flash only download it directly from Adobe.
    In all web browsers disable Java (but do leave Javascript on as that's something else).
    In all web browsers make sure downloaded files aren't set to automatically open after downloading.
    Consider disabling Java completely (launch Java Preferences in the Utilities folder and disable it - you'll likely rarely, if ever need it. If you do just turn it on and off again when your done).
    You can also check out this link:
    http://lifehacker.com/5900434/how-to-find-out-if-your-mac-was-infected-by-the-fl ashback-trojan-in-one-click

  • How to find the day of the week ?

    Hi,
    I want to find the day of the current date. Can you please let me know as to how to get the same ?
    My code is like :
    java.util.Date date = new java.util.Date();
    // Here i need to use a method to retrive the day of this date
    Your early input is appreciated.
    Regards

    Use a java.util.GregorianCalendar:
    GregorianCalendar calendar = new GregorianCalendar();
    System.out.println("DAY_OF_WEEK: " + calendar.get(Calendar.DAY_OF_WEEK));

  • How to display the day of the week?

    I can use the TODAY() function to display today's date, and I can format the cell with inspector to manipulate how to show the date, but how can I show only what the DAY of the week it currently is?

    The problem with these two responses is that they are language dependant.
    It would be useful to add a WEKDAYNAME() function which will return names according to the language in use.
    Here is a workaround:
    =LEFT(B,SEARCH(" ",B)-1)
    It just assumes that B contains a date with dayname at the beginning.
    Yvan KOENIG (from FRANCE mercredi 3 décembre 2008 22:05:06)

  • How can I use apple mail (linked to gmail) and get it to only do autofill on the contacts that I have in apple address book?

    How can I use apple mail (linked to gmail) and get it to only do autofill on the contacts that I have in apple address book? Everytime I write an email on the Apple mail app (as well as in Gmail) it recommends a bunch of emails that are not my contacts. I want it to just autofill for the contacts that I have in my address book. Is this possible? Thank you. I have an Imac Intel version and an Iphone 5 phone.

    Mail > Window > Previous Recipients

Maybe you are looking for

  • Close window on click of a button

    Hi all, I am developing an application in which there are some checkboxes with a button on the window. When we choose these checkboxes (one or more) and click on the button it opens another window which has some textfields and one button. These textf

  • ICaht doesn't quit, but video and audio stops and disconnects

    I have a brand new iMac G5 and so does my Mom. We both have the iSight camera imbedded in the iMac, both have high speed cable internet but cannot iChat for more than a few minutes without the video/audio chat stopping. This is what connection doctor

  • Audio/vide​o on PowerPoint not working

    Hi, The audio/video on my PowerPoint is not working.  Other sound is ok. Windows 7 & Microsoft Office PowerPoint 2007.   Please help, thanks.

  • How add the Video in Content Editor Webpart

    Hi All,  I have task to add the video in Content Editor Web-part.Can any one help me how can I add the video in Content Editor Web-part Samar

  • ALE : Fields Z are not transferred.

    Hi, we need transferring through ALE 3 fields of customers (Z) belonging to Infotype 21, but we have not been able to do that. What we have done: In Sender: 1.-Create segment ZE1P0021 with additional fields (we31). 2.-Create enhancement to object HRM