- From: Jeff <jeff@cogentlogic.com>
- Date: Wed, 7 Apr 2004 00:56:16 -0400
- To: "Robert Bateman" <bobbateman@sequoiallc.com>, <www-forms@w3.org>
Hi Bob,
For five vanilla days:
java.util.Calendar calNowPlusFive = java.util.Calendar.getInstance();
calNowPlusFive.add(Calendar.DATE, 5);
java.text.SimpleDateFormat sdfISO8601 = new
java.text.SimpleDateFormat("yyyy-MM-dd");
String strISO8601NowPlusFive =
sdfISO8601.format(calNowPlusFive.getTime());
// populate xsd:date with strISO8601NowPlusFive
For five business days:
java.util.Calendar calNowPlusFive = java.util.Calendar.getInstance();
int nIncrementForFiveBusinessDays = 5;
int nDayOfWeek = calNowPlusFive.get(Calendar.DAY_OF_WEEK);
if (nDayOfWeek == Calendar.MONDAY)
nIncrementForFiveBusinessDays = 7; // Monday + 5 =>
Saturday so add 2 to bump past weekend
else if (nDayOfWeek == Calendar.TUESDAY)
nIncrementForFiveBusinessDays = 6; // Tuesday + 5 =>
Sunday so add 1 to bump past weekend
calNowPlusFive.add(Calendar.DATE, nIncrementForFiveBusinessDays);
java.text.SimpleDateFormat sdfISO8601 = new
java.text.SimpleDateFormat("yyyy-MM-dd");
String strISO8601NowPlusFive =
sdfISO8601.format(calNowPlusFive.getTime());
// populate xsd:date with strISO8601NowPlusFive
Jeff
Cogent Logic
----- Original Message -----
From: "Robert Bateman" <bobbateman@sequoiallc.com>
To: <www-forms@w3.org>
Sent: Tuesday, April 06, 2004 12:20 PM
Subject: date calculations
I've looked thru as many of the examples from around the web as I can find
and
don't see an obvious way to do date calculations.
What I'm trying to do is populate an xsd:date field with now() plus 5 days
as
it's default value. The field in question is a proposed "due date" for a
work order.
I've seen that I can get a "difference" between two dates, but no
calculations.
Thanks Much!
Bob
Received on Wednesday, 7 April 2004 01:02:52 UTC