1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

OpenEdge 10.1C returns datetimetz as a non standard String in JDBC

Discussão em 'StackOverflow' iniciado por fdantas, Maio 8, 2015.

  1. fdantas

    fdantas Administrator Moderador

    I'm trying to access a DB field which represents a datetimetz ABL type. I tried ResultSet.getTimestamp(int) which should be correct , though the driver complains with [DataDirect][OpenEdge JDBC Driver]Value can not be converted to requested type..

    I've tried all date and time getters on ResultSet which none work. A call to ResultSet.getObject(int) returns a String representing the value, however this value is a non-standard format which actually has a quirk making it difficult to parse with a SimpleDateFormat, this format comes out looking like "2013-03-08 21:55:10:903 + 11:00".

    From this quirky date it can't be parsed cleanly with a format string due to the space after the +/- in the time-zone qualifier and I've had to resort to the following ugly method:

    String r = rs.getString(col);
    if (r == null) {
    return null;
    }
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSSXXX",
    Locale.getDefault());
    try {
    return df.parse(r.substring(0, 23)
    + r.substring(24, 25)
    + r.substring(26));
    } catch (ParseException ex) {
    return null;
    }


    I am using OpenEdge 10.1.C04

    Continue reading...

Compartilhe esta Página