.NET转换日期为Java日期 [英] Convert .net date to Java date

查看:114
本文介绍了.NET转换日期为Java日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的code,我收到格式化的日期: /日期(-82135555200000-0800)/

In my code, I'm receiving a date formatted: /Date(-82135555200000-0800)/

如何才能解析它在Java中,成为一个Java日期?

How can I parse it in Java to become a Java date?

推荐答案

字符串 /日期(-82135555200000-0800)/

使用此行code的中移除非数字元素字符串

use this line of code to remove non-number element from the String

String tempDate = data.getDate().replaceAll("\\D+", "");

你真正感兴趣的应该是 8213555520000 。你需要前15位数字,以从中获得的日期作为给定的时间是以毫秒为单位,你可以做任何你想用它。
许多语言遵循此约定,以便处理日期变得容易

what you actually be interested in should be 8213555520000 . you would need first 15 digits to get the date from it as the given time is in milliseconds, you can do whatever you want with it. Many languages follow this convention so dealing with date becomes easy

Date date = new Date(Long.parseLong(""+tempDate));

或者如下

String dateAsText = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
        .format(new Date(821355552*10000L)); 

这篇关于.NET转换日期为Java日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆