Thomas SMETS
Posts: 307
Nickname: tsmets
Registered: Apr, 2002
|
|
Re: batch function
|
Posted: Apr 8, 2002 7:15 AM
|
|
Your question is really to quickly formulated to be answered "like that" ... I believe you should reformulate.
Especially what do you mean by Launching a message ? _ Returning a String _ Send a mail _ Publish a JMS topic _ ...
> hi, > i would like to create a counter that increments and > compare itself to a date saved in record if equal > launching a message > how can i do that?
class Counter
{
private static int c_year = 0;
private static int c_day_of_year = 0;
private static int bumped = 0;
Counter()
{
}
public void bump()
{
// You may prefere the
// GregorianCalendar.getInstance(); // For efficiency reasons !
GregorianCalendar now = new GregorianCalendar();
// May also be willing ot check other things
// but this is the minimum (enough).
now_year = now.get(Calendar.YEAR);
now_day_of_year = now.get(Calendar.DAY_OF_YEAR);
if ( 0 == bumped++ )
{
c_year = now_year;
day_of_year = now_day_of_year;
sendMessage();
return;
} else
if ( c_year == now_year
|| day_of_year == now_day_of_year)
{
sendMessage();
)
}
}
Now for efficiency reasons (this will be run on a web server I suppose), you should wrap this in a Factory.
This is only a possible answer according to what I understood of your problem !
thomas tsmets @ lautre . net
|
|