Search code examples
javastringodataspecial-characters

Store Backward slash and forward slash in java string


I am parsing below string value into OData query through java code.

objects.put("EndDate", "\/Date(1441756800)\/";

How can i parse the /Date(1441756800)/ into a string in java.

I have tried with below :

objects.put("EndDate", ""\\""//"Date(1441756800)""\\""//"";

throws error:(


Solution

  • I never used OData so I may not understand your question correctly, but if you are asking how to write \/Date(1441756800)\/ as String then you need to escape \ as it is String special character (used for instance when escaping or when creating other special characters like line separators \n).

    So try with "\\/Date(1441756800)\\/"