0

現在、私の Android アプリでは、「作成された」日付は次の形式になっています: 2014-02-21 00:00:00

この形式にしたい: Feb 21 2014 00:00:00

このコードで再フォーマットできる場合は、誰かがその方法を教えてくれませんか?

@Override
protected void onPostExecute(String sJson) {
    if(sJson == null) {
        if(listener != null) listener.onFetchFailure(msg);
        return;
    }        

    try {
        // convert json string to json array
        JSONArray aJson = new JSONArray(sJson);
        // create apps list
        List<Application> apps = new ArrayList<Application>();

        for(int i=0; i<aJson.length(); i++) {
            JSONObject json = aJson.getJSONObject(i);
            Application app = new Application();
            app.setTitle(json.getString("app_title"));
            app.setDesc(json.getString("description"));               
            app.setCreator(json.getString("creator"));
            app.setCreated(json.getString("created"));
            app.setRank(json.getString("rating"));  
            app.setIcon(json.getString("icon"));

            // add the app to apps list
            apps.add(app);
        }

        //notify the activity that fetch data has been complete
        if(listener != null) listener.onFetchComplete(apps);
    } catch (JSONException e) {
        msg = "Invalid response";
        if(listener != null) listener.onFetchFailure(msg);
        return;
    }        
}
4

1 に答える 1

0

以下を試してください:

            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    SimpleDateFormat sdf1=new SimpleDateFormat("MMM dd yyyy hh:mm:ss");
    app.setCreated(sdf1.format(sdf.parse(json.getString("created"))));
于 2014-03-18T13:57:41.983 に答える