Sundays


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Sundays

  1. #1
    Join Date
    Aug 2002
    Posts
    3

    Question Sundays

    I dont know how to find out if a date given to java is a sunday.

    The Date is in the form of three variables which are strings

    The three variables are Day / Month / Year

  2. #2
    Join Date
    Jul 2002
    Posts
    60

    Post

    Hello SPC,
    You'll need to format it with a variety of methods.
    In looking at the java 1.3.1 api, I found that the DATE class is deprecated, and CALENDAR is now utilized.

    You can read all about the Calendar class and its method calls at:
    http://java.sun.com/j2se/1.3/docs/ap.../Calendar.html

    Truthfully, I have no quick answer for you, except to suggest reading the above to figure out which variables are best for you and how to set them.

    It looks like the Calendar class works with integer variables. So, you'll definitely need to reformat your Strings to integers.

    If you have a String input from a user, you can convert it to an integer like this:

    String day = "7";
    int sunday = 7;
    /*
    if you try int sum = day + sunday, you'll throw an error because you're trying to add a string to a number;
    so you need to convert String day to an integer, like this:
    */
    String day = "7";
    int day = Integer.parseInt(day);
    int sunday = 7;
    int sum = day + sunday;
    System.out.println(sum);

    //when compiled and run, you'll get the sum of int day and int sunday: 14.

    ~Jim
    PS: Trying to convert it back?? // integer to a String ?
    String day = "7"; // an existing string variable
    int day = Integer.parseInt(day); //converts the string to an integer
    String newday = Integer.toString(day);

  3. #3
    Join Date
    Aug 2002
    Posts
    3

    Question

    Thanks for this info

    but

    How do I do this in JavaScript so I can use it in HTML?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center