Skip to content
Advertisement

Tag: parsing

How to format date/time string? (Java)

Hi can anyone help please? I am trying to format a date and time string. Currently it looks like this “20160112T110000Z” and I need it to be “2016-01-12T11:00:00Z” The string without the special characters are returned from a 3rd party recurrence library. I need to convert it to have the special characters before parsing it to a Calendar object. Can

Unexpected character (“) at position 2 JSON Parser (Java)

Here is my JSON File beginning: And here is my Parser: I am trying to parse through this JSONfile using a FileReader and JSON and JSON-Simple libraries. I think my format of my JSON file is correct but I don’t know how to get past this error: Answer Your JSON is not correct. Kindly check It should be something like

“Expected BEGIN_OBJECT but was STRING at line 1 column 1”

I have this method: And I want to parse a JSON with: But I get an error message: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 Answer Even without seeing your JSON string you can tell from the error message that it is not the correct structure to be parsed into an instance of your class.

Unparsable Date with colon-separated timezone

I’m trying to parse this String 2014-04-04T14:28:38+02:00 It should be ISO 8601 format. But i can’t parse it to a correct Date. I’ve tried the following: But I get always the message “unparseable Date” I can not change the example because it’s a value from a webservice. Could it be there is a probleme with “+02:00” instead of “+0200” ?

Efficient way to extract protocol data units from tcp byte stream

I’ve had two java projects (simple multiplayer games) that relied on a byte-based connection-oriented protocol for communication. In both cases I was unhappy with the implementation of the communication, since I couldn’t come up with an intelligent, non-verbose and object-orientied way of writing and especially parsing the bytes. For writing I had something like That was acceptable to some extent,

How parse 2013-03-13T20:59:31+0000 date string to Date

How to parse this format date string 2013-03-13T20:59:31+0000 to Date object? I’m trying on this way but it doesn’t work. I get this exception from the first line: java.lang.IllegalArgumentException: Illegal pattern character ‘T’ Answer DateFormat df = new SimpleDateFormat(“yyyy-MM-dd’T’hh:mm:ssZ”); Year is lower case y. Any characters that are in the input which are not related to the date (like the

Advertisement