2016-04-28 17 views
2

Ruby On Rails Frameworkで構築されたAPIからデータを取得するAndroid Appをビルドしています。 00::
はここに私のタイムスタンプ文字列
2000-01-01T12ある00.000ZAndroid Ruby on Railsタイムスタンプを日付に変換する

私はReadable日付と時刻の形式すなわち「土曜日1月1日、2000年午前12時00分」

答えて

1

に変換する必要がありますこれを試すことができます:

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; 
} 
1

私は同じ問題を抱えていましたが、@ 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; 
} 

の書式は私にjeudi décembre 22, 2016 at 16:42 PMを与えたが、あなたがたDateFormat

を調整することができます
関連する問題