-
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
-
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);
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks