Convert Server Time into Current time or Local time

时间:2016-04-25 09:39:59

标签: android-studio datetime-format

  • I am getting time from server and i am parsing that time in activity
  • I know there are so many answers available , but none works for me. I tried most of them

-- Code :

  SimpleDateFormat dateFormat2 = new SimpleDateFormat("hh:mm a MM/dd");
        SimpleDateFormat hh_mm_ss = new SimpleDateFormat("yyyy-MM-dd HH:mm");

        hh_mm_ss.setTimeZone(TimeZone.getTimeZone("UTC"));


        try {
            dat1 = hh_mm_ss.parse(arraylist.get(position).get("createdate"));
            Log.e("time", dat1.toString());
            String out = dateFormat2.format(dat1);
            tvTime.setText(out);
        } catch (ParseException e) {
            e.printStackTrace();
        }

-- Log :

E/time: Mon Apr 25 07:59:00 GMT+05:30 2016

-- But when is print in Text-view it gives me server time only, not local time

0 个答案:

没有答案