Dukascopy Support Board
http://www.dukascopy.com/swiss/english/forex/jforex/forum/

Datum nach Long, Parse, ParseException
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=156&t=51898
Page 1 of 1

Author:  Sakurai78 [ Wed 19 Nov, 2014, 13:14 ]
Post subject:  Datum nach Long, Parse, ParseException

Hallo,

das hier kam meiner Frage schon nahe:
viewtopic.php?f=88&t=43723&p=56952&hilit=parse+date#p56952
Aber 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 {}

}

Author:  Mikelis_Zandberg [ Mon 24 Nov, 2014, 12:02 ]
Post subject:  Re: Datum nach Long, Parse, ParseException

Hallo,

vielen Dank für Ihre Frage.
Diese Forum-Abschnitt ist für "Visual JForex" Fragen und leider kann ich Ihnen beim Java programmieren nicht viel helfen.
Bitte stellen Sie diese Frage im Forum-Abschnitt: Dukascopy Support Board - Automated Trading.
Mein Kollege (Englischsprachig) wird Ihnen dabei helfen.

  Page 1 of 1