date format and converting that date to JodaTime

主宰稳场 提交于 2019-12-25 04:26:17

问题


I want to use date as a parameter with a url call in the following format YYYYMMDDHHMMSS.When i checked java Date it is in how can i do that in java ? or i have to give time manually using the below code?

public static long start_date=20140423101010L;

the above variable has a date from the year 2014 month 04, date 23, and time hour :10., min:10 and sec :10. I want this time in the above format (YYYYMMDDHHMMSS) to JodaTime.

Is it possible to do that?


回答1:


Try

DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyyMMddHHmmss");
DateTime dateTime = formatter.parseDateTime(String.valueOf(start_date));


来源:https://stackoverflow.com/questions/24324149/date-format-and-converting-that-date-to-jodatime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!