Hallo,
das hier kam meiner Frage schon nahe:
viewtopic.php?f=88&t=43723&p=56952&hilit=parse+date#p56952Aber auch damit bekomme ich dieselbe Fehlermeldung "Unhandled exception type ParseException".
Bitte helfen Sie mir:
Wo steckt im Code unten der Fehler?
Für die Zeile
dt = df.parse("2014-11-19 09:30");
bekomme ich
die Meldung "Unhandled exception type ParseException".
Vielen Dank,
Jan-C. Weihgold
package jforex.strategies.sdk;
import java.util.*;
import java.text.*;
import com.dukascopy.api.*;
public class DateParseTest implements IStrategy {
private IChart chart;
private IHistory history;
private IConsole console;
@Override
public void onStart(IContext context) throws JFException {
IConsole c = context.getConsole();
Date dt = new Date();
// Festlegung des Formats:
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
df.setTimeZone( TimeZone.getDefault() ); // nicht mehr unbedingt notwendig seit JDK 1.2
// Formatierung zu String:
c.getInfo().println( "Date = " + df.format( dt ) ); // z.B. '2001-01-26 19:03:56.731'
// Einlesen vom String:
dt = df.parse("2014-11-19 09:30");
c.getInfo().println( "parse = " + df.format( dt ) ); // z.B. '2001-02-03 04:05:06.7'
/* DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") {{ setTimeZone(TimeZone.getTimeZone("GMT 0")); }};
Calendar calendar = Calendar.getInstance();
System.out.println(String.format("...",
TimeZone.getDefault().getDisplayName(), // 1
calendar.getTime(), // 2
formatter.format(calendar.getTime()), // 3
formatter.parse(formatter.format(calendar.getTime())))); // 4
*/
}
@Override
public void onTick(Instrument instrument, ITick tick) throws JFException {}
@Override
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}
@Override
public void onMessage(IMessage message) throws JFException {}
@Override
public void onAccount(IAccount account) throws JFException {}
@Override
public void onStop() throws JFException {}
}