[英]How to convert “\/Date(1262300400000+0100)\/” to Java Date instance and vice versa?
I am getting on android client from C# server Date like string with format "\\/Date(1262300400000+0100)\\/"
. 我从C#服务器Date上获取android客户端,例如格式为"\\/Date(1262300400000+0100)\\/"
字符串。 (part of json object) How to convert this to Java Date instance and vice versa ? (json对象的一部分)如何将其转换为Java Date实例,反之亦然? I need to show this in readable format. 我需要以可读格式显示此内容。
Take out the numbers: 取出数字:
String numbers = str.replaceAll("\\\\/Date\\((\\d+\\+\\d+)\\)\\\\/", "$1+$2");
Split on the plus (+) sign. 在加号(+)上分开。
String parts = numbers.split("\\+");
Convert to Date: 转换为日期:
Date d = new Date(Long.parseLong(parts[0]));
However, I'm not sure on what to do with the TimeZone. 但是,我不确定如何使用TimeZone。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.