Is there a simple way to convert timestamp to date time in android while fetching data from Json?

戏子无情 提交于 2020-05-24 05:17:11

问题


JsonArrayRequest request = new JsonArrayRequest(Request.Method.GET,url, null,
            new Response.Listener<JSONArray>() {
                @Override
                public void onResponse(JSONArray response) {
                    progressDialog.dismiss();

                        try{
                            for (int i = response.length()-1; i>=0 ; i--){
                            JSONObject jsonObject = response.getJSONObject(i);

                            UpdateList value = new UpdateList(jsonObject.getString("update"),jsonObject.getString("timestamp"));

                            mData.add(value);
                            }
                            notificationAdapter= new NotificationAdapter(getActivity(),mData);
                            NewRecyclerView.setAdapter(notificationAdapter);
                        }catch (JSONException e){
                            e.printStackTrace();
                        }
                    }
            },new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            progressDialog.dismiss();
            Toast.makeText(getActivity(),error.getMessage(),Toast.LENGTH_LONG).show();
        }
    });

Here, I get a timestamp from JsonObject. I want to convert it into Date time instantly after getting data. what to do?

来源:https://stackoverflow.com/questions/61351287/is-there-a-simple-way-to-convert-timestamp-to-date-time-in-android-while-fetchin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!