Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在从 C# 服务器 Date like string with format 获取 android 客户端"\/Date(1262300400000+0100)\/"。(json 对象的一部分)如何将其转换为 Java Date 实例,反之亦然?我需要以可读的格式显示它。
"\/Date(1262300400000+0100)\/"
取出数字:
String numbers = str.replaceAll("\\\\/Date\\((\\d+\\+\\d+)\\)\\\\/", "$1+$2");
在加号 (+) 上拆分。
String parts = numbers.split("\\+");
转换为日期:
Date d = new Date(Long.parseLong(parts[0]));
但是,我不确定如何处理 TimeZone。