So my goal this time is to compare the varibale USDCHF_DATE who's value is 2005/06/06 17:00 with the variable formatedDATE who's value is 2006/10/30 15:27
CODE HERE:
import com.javaparts.dde.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.text.ParseException;
import java.util.Date;
public class CompareDDETime {
public static void main(String[] args) {
DDEClient client;
Conversation sheet1 = null;
client = DDEClient.getInstance();
// Make a new Date object. It will be initialized to the current time.
Date now = new Date();
SimpleDateFormat format =
new SimpleDateFormat("yyyy'/'MM'/'dd HH:mm");
String formatedDATE = format.format(now);
System.out.println("Current time is " + formatedDATE);
try {
sheet1 = client.connect("Excel", "Sheet1");
System.out.println("Connected to Excel Sheet1");
System.out.println("");
String USDCHF_DATE = new String(sheet1.request("R3C7"));
String GBPUSD_DATE = new String(sheet1.request("R4C7"));
String USDJPY_DATE = new String(sheet1.request("R5C7"));
String EURUSD_DATE = new String(sheet1.request("R6C7"));
System.out.println("The last USDCHF modification date from the DDE Server was at " + USDCHF_DATE);
System.out.println("The last GBPUSD modification date from the DDE Server was at " + GBPUSD_DATE);
System.out.println("The last USDJPY modification date from the DDE Server was at " + USDJPY_DATE);
System.out.println("The last EURUSD modification date from the DDE Server was at " + EURUSD_DATE);
// if (EURUSD_DATE < formatedDATE) {
// System.err.println("All is well!");
// } else {
// System.err.println("Problem deteced!");
// }
} catch(DDEException e) {
System.out.println(e);
} finally {
// disconnect in a finally clause
try {sheet1.close();} catch (Exception e) {}
}
client.close();
}
}
The Scripts output is like so:
C:\Program Files\DDEForJava\examples\com\javaparts\dde\examples>java CompareDDET
ime
Connected to Excel Sheet1
The last USDCHF modification date from the DDE Server was at 2005/06/06 17:00
The last GBPUSD modification date from the DDE Server was at 2005/06/06 17:00
The last USDJPY modification date from the DDE Server was at 2005/06/06 17:00
The last EURUSD modification date from the DDE Server was at 2005/06/06 17:00

New Topic/Question
Reply




MultiQuote




|