Java Question

I have a java agent that pulls information from a hail website. I know I can hard code the dates in, but I want to be able to run this with the current days date. How would I do this?

Here’s my agent:

import lotus.domino.*;

import java.net.*;

import java.io.*;

public class JavaAgent extends AgentBase {

public void NotesMain() {

//public void NotesMain() {

try {

//Create variables

Session session = getSession();

AgentContext ac = session.getAgentContext();

Database db = ac.getCurrentDatabase();

Document doc = db.createDocument();

RichTextItem xml = doc.createRichTextItem(“XMLData”);

//RichTextItem xml = doc.createRichTextItem(“XMLDataHTML”);

DateTime dt = session.createDateTime(“Today”);

//Set the value of the document fields

doc.appendItemValue(“Form”, “RawEXRData”);

dt.setNow();

doc.appendItemValue(“Date”, dt);

//importing html instead of xml

//HERE IS AN EXAMPLE OF THE URL WITH DATES INCLUDED:

URL EXRates = new URL(“http://hailreports.net/advanced_search.php?start_date=06%2F27%2F2012&end_date=06%2F30%2F2012&address=&radius=&size=&adv-srch=Search”);

//I JUST WANT TO RUN IT DAILY WITH CURRENT DATE

BufferedReader in = new BufferedReader (new InputStreamReader(EXRates.openStream()));

String inputLine;

//Loop through every line of the URL and write it out to a RichText Field

while ((inputLine = in.readLine()) != null) {

xml.appendText(inputLine.toString());

xml.addNewLine();

} //try

//Save the document and close the reader

doc.save(true, true);

in.close();

}catch(Exception e) { e.printStackTrace(); } //catch

} //NotesMain

} //public class

Thank you in advance.

Subject: Java Question

Lisa, try this:

DateTime startDate = this.getSession().createDateTime(“Today”);

DateTime endDate = this.getSession().createDateTime(“Today”);

endDate.adjustDay(10); // add 10 days

String startDateString = new java.text.SimpleDateFormat(“MM/dd/yyyy”).format(startDate.toJavaDate());

String endDateString = new java.text.SimpleDateFormat(“MM/dd/yyyy”).format(endDate.toJavaDate());

String encodedStartDateString = “”;

String encodedEndDateString = “”;

try

{

   encodedStartDateString = java.net.URLEncoder.encode(startDateString, "UTF-8");

   encodedEndDateString = java.net.URLEncoder.encode(endDateString, "UTF-8");

}

catch(Exception exc) {}

URL EXRates = new URL(“http://hailreports.net/advanced_search.php?start_date=” + encodedStartDateString +

                  "&end_date=" + encodedEndDateString + "&address=&radius=&size=&adv-srch=Search");

Gary