相关疑难解决方法(0)

Java: unparseable date exception

While trying to transform the date format I get an exception:unparseable date and don't know how to fix this problem.

I am receiving a string which represents an event date and would like to display this date in different format in GUI.

What I was trying to do is the following:

private String modifyDateLayout(String inputDate){
        try {
            //inputDate = "2010-01-04 01:32:27 UTC";
            Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z").parse(inputDate);
            return new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(date);
        } catch (ParseException e) {
            e.printStackTrace();
            return …
Run Code Online (Sandbox Code Playgroud)

java format date

26
推荐指数
1
解决办法
16万
查看次数

标签 统计

date ×1

format ×1

java ×1