简体   繁体   English

在Java字符串中存储反斜杠和正斜杠

[英]Store Backward slash and forward slash in java string

I am parsing below string value into OData query through java code. 我正在通过Java代码将字符串值以下解析为OData查询。

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

How can i parse the /Date(1441756800)/ into a string in java. 我如何将/ Date(1441756800)/解析为Java中的字符串。

I have tried with below : 我尝试了以下方法:

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

throws error:( 引发错误:(

试试这个objects.put("EndDate", "'Date(1441756800)'";

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 ). 我从未使用过OData,所以我可能无法正确理解您的问题,但是如果您要问如何将\\/Date(1441756800)\\/编写为String,则需要转义\\因为它是String的特殊字符(例如,用于转义或创建其他特殊字符(如行分隔符\\n )时。

So try with "\\\\/Date(1441756800)\\\\/" 因此,尝试使用"\\\\/Date(1441756800)\\\\/"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM