Invalid time zone indicator ' '

See original GitHub issue

This my Gson code:

protected Object fromJson(String json, Type t) {
try {
			Gson g = new Gson();
			Object o = g.fromJson(json, t);
			return o;
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			return null;
  }
}

I have an object which have a 2 Timestamp fields and I want to consume a json response using Gson but I have got an Invalid time zone indicator ’ '.But this is not always happening. I don’t know why. So this is out put :

Caused by: java.text.ParseException: Failed to parse date ["2018-04-12 18:38:02']: Invalid time zone indicator ' '
	at com.google.gson.internal.bind.util.ISO8601Utils.parse(ISO8601Utils.java:274) ~[gson-2.8.2.jar!/:?]
	at com.google.gson.internal.bind.DateTypeAdapter.deserializeToDate(DateTypeAdapter.java:72) ~[gson-2.8.2.jar!/:?]
	... 106 more
Caused by: java.lang.IndexOutOfBoundsException: Invalid time zone indicator ' '
	at com.google.gson.internal.bind.util.ISO8601Utils.parse(ISO8601Utils.java:245) ~[gson-2.8.2.jar!/:?]
	at com.google.gson.internal.bind.DateTypeAdapter.deserializeToDate(DateTypeAdapter.java:72) ~[gson-2.8.2.jar!/:?]
	... 106 more

This my Gson data:

[
    {
        "id": 2267,
        "code": "2100130106335294543080001",
        "name": "ly123",
        "servicetype": "VOD",
        "showname": "ly123",
        "type1": 1,
        "pictureurl1": "",
        "pictureurl2": "",
        "status": 1,
        "isdelete": false,
        "checkstatus1": 10,
        "createtime": "2018-04-12 18:38:02",
        "updatetime": "2018-04-12 18:38:15",
        "description": "",
        "sgs": [],
        "sgCodes": [],
        "isPool": false
    }
]

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

13reactions
7788jaycommented, Jun 29, 2018

@fradrick Need to set the time format to use, the default is not the standard format. new GsonBuilder().setDateFormat(“yyyy-MM-dd HH:mm:ss”)

6reactions
7788jaycommented, May 23, 2018

我也碰到了

Read more comments on GitHub >

github_iconTop Results From Across the Web

Convert String date to Object yields Invalid time zone indicator '0'
Failed to parse date ["1476399300000']: Invalid time zone indicator '0' (at offset 0). Both sides are working with java.util.Date.
Read more >
invalid time zone indicator gson
Using GSON, a problem arose with this date format. It was fine parsing the string into a Date object, but it was expecting...
Read more >
Java example source code file (ISO8601Utils.java)
Java example source code file: ISO8601Utils.java (calendar, indexoutofboundsexception, invalid, numberformatexception, string, timezone_utc)
Read more >
Caused by: java.text.ParseException: Failed to parse date ...
ParseException: Failed to parse date ["1588301291556"]: Invalid time zone indicator '9' at com.google.gson.internal.bind.util.
Read more >
Example usage for java.lang IndexOutOfBoundsException ...
... null) { throw new IndexOutOfBoundsException("Invalid time zone indicator "); } TimeZone timezone = TimeZone.getTimeZone(timezoneId); if (!timezone.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found