Java Android将Ruby on Rails时间戳转换为日期时间

Java Android将Ruby on Rails时间戳转换为日期时间,java,android,timestamp,Java,Android,Timestamp,我正在构建一个Android应用程序,从Ruby On Rails框架中构建的API获取数据。 这是我的时间戳字符串 2000-01-01T12:00:00.000Z 我需要将其转换为可读的日期和时间格式,即“2000年1月1日星期六上午12:00”您可以尝试以下方法: public static String convertDate(String oldDateString){ String format = "yyyy-MM-dd'T'HH:mm:ss.sssZZZZ";

我正在构建一个Android应用程序,从Ruby On Rails框架中构建的API获取数据。
这是我的时间戳字符串
2000-01-01T12:00:00.000Z

我需要将其转换为可读的日期和时间格式,即“2000年1月1日星期六上午12:00”

您可以尝试以下方法:

public static String convertDate(String oldDateString){
    String format = "yyyy-MM-dd'T'HH:mm:ss.sssZZZZ";

    SimpleDateFormat sdf = new SimpleDateFormat(format);
    Date date = null;
    try {
        date = sdf.parse(oldDateString);
    } catch (ParseException e) {
        // handle exception here !
    }

    String newFormatString = "MMMM dd, yyyy 'at' HH:mm a";

    SimpleDateFormat newFormatter = new SimpleDateFormat(newFormatString);



    String newDateString = newFormatter.format(date);

    return newDateString;
}

我也有同样的问题,我尝试了@real19答案,但它给了我错误。 那时候我就来了:

  public static String convertDate(String oldDateString){
    String format = "yyyy-MM-dd'T'HH:mm:ss.sss";

    SimpleDateFormat sdf = new SimpleDateFormat(format);
    Date date = null;
    try {
        date = sdf.parse(oldDateString);
    } catch (ParseException e) {
        // handle exception here !
        e.printStackTrace();
    }

    String newFormatString = "EEEE MMMM dd, yyyy 'at' HH:mm a";

    SimpleDateFormat newFormatter = new SimpleDateFormat(newFormatString);

    String newDateString = newFormatter.format(date);

    return newDateString;
}
2016年12月22日下午16:42,格式化给了我
jeudi décembre
,但你可以调整日期格式