【问题标题】:Parse Timestamp into readable format (Android)将时间戳解析为可读格式(Android)
【发布时间】:2015-02-05 18:02:07
【问题描述】:

我需要转换以下时间戳

 String s = "08-12-2014 05:00:00"

 to a readable format like "Today 5am"

请建议我如何做到这一点或我可以使用的库。

顺便说一句,我试过了

      String ago = hourly.getHour(j).time() ;
            SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",  Locale.ENGLISH);
            Date d = inputFormat.parse(ago);
            SimpleDateFormat outputFormat=   new SimpleDateFormat("EEEE, MMMM dd, yyyy HH:mm  a");

【问题讨论】:

标签: java android timestamp simpledateformat


【解决方案1】:
     SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",  Locale.ENGLISH);
     SimpleDateFormat outputFormat=   new SimpleDateFormat("EEEE, MMMM dd, yyyy HH:mm  a");

    try {
        Date oneWayTripDate = inputFormat.parse(datedata);
    } catch (java.text.ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
String  datetime=    outputFormat.format(oneWayTripDate);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-21
    • 2012-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-23
    • 1970-01-01
    • 2011-07-21
    相关资源
    最近更新 更多