sql server - Java.sql.sqlexception: The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value -
when updating date field update not works netbeans , below exception raised
java.sql.sqlexception: conversion of char data type datetime data type resulted in out-of-range datetime value
however run same query query works fine in sql query analyzer (sql server 2000)
i formatting date value updated follows in netbeans.
jxdatepicker jdatepicker = (jxdatepicker) comp; date date = jdatepicker.getdate(); if (date != null) { try { string expectedpattern = "yyyy-mm-dd hh:mm:ss.sss"; string currentformat = "dd-mm-yyyy hh:mm:ss.sss"; simpledateformat dateformatreq = new simpledateformat(expectedpattern); simpledateformat dateformatcurr = new simpledateformat(currentformat); // convert date required format db //first prepare string in current format dd-mm-yyyy // convert date in current format dd-mm-yyyy // convert string in desired format yyyy-mm-dd string strdate = dateformatreq.format(dateformatcurr.parse(dateformatcurr.format(date))); } catch (parseexception ex) { logger.getlogger(changejcontrolproperties.class.getname()).log(level.severe, null, ex); } } string query =update mytable set date=strdate id=mydd
for date 2013-07-05 updates successfully.
for date 2013-06-28 displays above exception
the problem has been solved default language selected thai, when change english exception not come , problem disappears.
Comments
Post a Comment