lundi 23 mars 2015

String.format and SimpleDateformat resulting in strange characters (Android / Java)

In the live version of one of my apps, I receive following exception multiple times and I can't figure out whats the reason:



no such column: ٥: , while compiling: SELECT id FROM table WHERE other_id = 9 AND DATE(substr(date,7,4)||substr(date,4,2)||substr(date,1,2)) > DATE(٢٠١٥٠٣٢٣) ORDER BY DATE(substr(date,7,4)||substr(date,4,2)||substr(date,1,2)) ASC LIMIT ٠,٥


The SQL Statement should select ids of events after a given time. In Java, it looks like this:



SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Date d = new Date();
String whereClause = "DATE(substr(date,7,4)||substr(date,4,2)||substr(date,1,2)) > DATE(" + sdf.format(d) + ") ";
String limit = String.format("%d,%d", lowerLimit, upperLimit);


So I'm using SimpleDateFormat (resulting in "DATE(٢٠١٥٠٣٢٣)") and String.format (resulting in "LIMIT ٠,٥") to format my SQLite Query and 99% of all times it works well.


The app is available in all countries, maybe it is some kind of localization issue?


Aucun commentaire:

Enregistrer un commentaire