我正在添加这个问题,因为我是Java和Android的新手,我搜索了几个小时试图解决这个问题.答案来自相关答案的组合,所以我想我会记录我为其他可能正在努力的人学到的东西.见答案.
对于一些背景知识,我的经验主要是PHP的Web开发和一点Ruby.我唯一的操作系统是Linux(Ubuntu Studio),我(不情愿地)在Android Studio 2.1.2中开发我的第一个Android应用程序.我的Java设置如下:
>java -version
> openjdk version "1.8.0_91"
> OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-3ubuntu1~15.10.1-b14)
> OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)
Run Code Online (Sandbox Code Playgroud) datetime android android-gradle-plugin threetenbp threetenabp
I have a string from a json response:
start: "2013-09-18T20:40:00+0000",
end: "2013-09-18T21:39:00+0000",
Run Code Online (Sandbox Code Playgroud)
How do i convert this string to a java DateTime Object?
i have tried using the following:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
start = sdf.parse("2013-09-18T20:40:00+0000");
Run Code Online (Sandbox Code Playgroud)
but with this i can only create a Date Object. But the time binded in the String is kinda essential.
Any Help is greatly appreciated!
我有一个带有此值的字符串,例如:"20130211154717"我希望它像"2013-02-11 15:47:17".我怎样才能做到这一点?