The Artima Developer Community
Sponsored Link

Java Answers Forum
batch function

1 reply on 1 page. Most recent reply: Apr 8, 2002 7:15 AM by Thomas SMETS

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
chantal

Posts: 1
Nickname: chantal
Registered: Apr, 2002

batch function Posted: Apr 6, 2002 6:36 AM
Reply to this message Reply
Advertisement
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?


Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: batch function Posted: Apr 8, 2002 7:15 AM
Reply to this message Reply
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

Flat View: This topic has 1 reply on 1 page
Topic: jexegen - not working - does it support Swing? java.io.*? Previous Topic   Next Topic Topic: html and applets

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use