Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid SimpleDateFormat parses wrong
    primarykey
    data
    text
    <p>I am having a date parse problem. In my app I retrieve new comments from our server. The retrieved epoch long timestamps are correct, but when I try to save them to the sqlite db sometimes the last comments parses the date wrong.</p> <p>SimpleDateFormat:</p> <pre><code>this.dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); this.dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); </code></pre> <p>Parsing:</p> <pre><code>Log.v("GET COMMENT TIME A", ""+cu.getString(cu.getColumnIndex("creation_time"))); try { Log.v("GET COMMENT TIME B",""+dateFormat.parse(cu.getString(cu.getColumnIndex("creation_time")))); c.setCreation_time(dateFormat.parse(cu.getString(cu.getColumnIndex("creation_time")))); Log.v("GET COMMENT TIME C", ""+c.getCreation_time()); } catch (ParseException e) {} </code></pre> <p>Logcat: previous comments parsed GOOD</p> <pre><code>01-13 13:01:58.009: V/GET COMMENT TIME A(10536): 2013-01-13 12:01:37 01-13 13:01:58.017: V/GET COMMENT TIME B(10536): Sun Jan 13 13:01:37 CET 2013 01-13 13:01:58.017: V/GET COMMENT TIME C(10536): Sun Jan 13 13:01:37 CET 2013 </code></pre> <p>Logcat: last comment parsed WRONG:</p> <pre><code>01-13 13:01:58.064: V/GET COMMENT TIME A(10536): 2013-01-13 12:01:41 01-13 13:01:58.064: V/GET COMMENT TIME B(10536): Sun Jan 13 13:01:41 CET 2013 01-13 13:01:58.064: V/GET COMMENT TIME C(10536): Tue Jan 01 13:01:41 CET 2013 </code></pre> <p>So when you look at logcat GET COMMENT TIME B and C, you can see that</p> <pre><code>dateFormat.parse(cu.getString(cu.getColumnIndex("creation_time"))) </code></pre> <p>first returns a corrected parsed time and 1 line further it parses another wrong time? Or why does the getCreation_time() return a wrongly parsed date sometimes?</p> <p>edit: the comment just has getter ans setters</p> <pre><code>public Date getCreation_time() { return creation_time; } public void setCreation_time(Date creationTime) { this.creation_time = creationTime; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload