Android Arabic Locale, Ormlite throw "Problems with column 5 parsing date-string

653 views
Skip to first unread message

AppYet.Dev

unread,
Jul 20, 2011, 10:39:49 AM7/20/11
to ormlite-android
My application allow user to change to different locale. We added new
language Arabic locale code ar. Ormlite start throw exception when
perform simple operation ".queryForAll()" Following is error message
07-20 10:13:52.875: ERROR/appyet(26230): Problems with column 5
parsing date-string '2011-07-19 00:02:45.000000' using 'yyyy-MM-dd
HH:mm:ss.SSSSSS'

Gray Watson

unread,
Jul 20, 2011, 1:02:59 PM7/20/11
to ormlite...@googlegroups.com
Folks, PLEASE PLEASE PLEASE post the entire exception when you get one.
gray

Udi Cohen

unread,
Jan 31, 2012, 7:05:08 PM1/31/12
to ormlite...@googlegroups.com
I have a stack trace. Happened on ORMLite 4.27

Caused by: java.sql.SQLException: Problems with column 1 parsing date-string '2012-01-22 12:00:00.000677' using 'yyyy-MM-dd HH:mm:ss.SSSSSS'
at com.j256.ormlite.misc.SqlExceptionUtil.create(SqlExceptionUtil.java:22)
at com.j256.ormlite.field.types.DateStringType.resultToJava(DateStringType.java:54)
at com.j256.ormlite.field.FieldType.resultToJava(FieldType.java:723)
at com.j256.ormlite.stmt.mapped.BaseMappedQuery.mapRow(BaseMappedQuery.java:59)
at com.j256.ormlite.android.AndroidDatabaseConnection.queryForOne(AndroidDatabaseConnection.java:146)
at com.j256.ormlite.stmt.mapped.MappedQueryForId.execute(MappedQueryForId.java:38)
at com.j256.ormlite.field.FieldType.assignField(FieldType.java:494)
at com.j256.ormlite.stmt.mapped.BaseMappedQuery.mapRow(BaseMappedQuery.java:63)
at com.j256.ormlite.android.AndroidDatabaseConnection.queryForOne(AndroidDatabaseConnection.java:146)
at com.j256.ormlite.stmt.mapped.MappedQueryForId.execute(MappedQueryForId.java:38)
at com.j256.ormlite.stmt.StatementExecutor.queryForId(StatementExecutor.java:79)
at com.j256.ormlite.dao.BaseDaoImpl.queryForId(BaseDaoImpl.java:200)
at com.anydo.client.dao.TaskHelper.getTaskById(TaskHelper.java:381)
... 17 more
Caused by: java.text.ParseException: Unparseable date: "2012-01-22 12:00:00.000677"
at java.text.DateFormat.parse(DateFormat.java:626)
at com.j256.ormlite.field.types.BaseDateType.parseDateString(BaseDateType.java:39)
at com.j256.ormlite.field.types.DateStringType.resultToJava(DateStringType.java:52)

Gray Watson

unread,
Feb 1, 2012, 11:23:12 AM2/1/12
to ormlite...@googlegroups.com
On Jan 31, 2012, at 7:05 PM, Udi Cohen wrote:

> I have a stack trace. Happened on ORMLite 4.27
>
> Caused by: java.sql.SQLException: Problems with column 1 parsing date-string '2012-01-22 12:00:00.000677' using 'yyyy-MM-dd HH:mm:ss.SSSSSS'

Huh. Seems like this is a locale issue. What's the right solution here? To force the local to be US or something when it does the parse?

gray

Udi Cohen

unread,
Feb 6, 2012, 4:20:22 AM2/6/12
to ormlite...@googlegroups.com
Actually I couldn't reproduce it. I've tries working on Arabic local with the date format set to YYYY-MM-DD as they do, but still couldn't make this happen again.

I don't want to force my own local everytime I work with dates, there are a lot of places to update and It could just bring more trouble...

Any suggestions on how to fix this? Even the error message implicate that the date is on the format expected..

Gray Watson

unread,
Feb 6, 2012, 12:51:35 PM2/6/12
to ormlite...@googlegroups.com
On Feb 6, 2012, at 4:20 AM, Udi Cohen wrote:

> Any suggestions on how to fix this? Even the error message implicate that the date is on the format expected..

You can specify the format to use when converting to/from a string date. See here:

http://goo.gl/rvd3O

You may have to do some data conversions to get this to work if some of your rows are in different formats than others.
gray

Reply all
Reply to author
Forward
0 new messages