0

From API i get time as string "13:00:00Z" in this format and it is GMT 0 time zone.

I want to adjust it to my time zone which is GMT +4.

  • https://stackoverflow.com/questions/36860468/how-to-convert-utc-date-to-locale-gmt-time-on-android – Vencat Nov 22 '22 at 00:52

1 Answers1

1

First you convert time into utc then after convert utc time to your local time zone. like example:

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault());
                    simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
                    try {
                        Date utcDate = simpleDateFormat.parse("Your date");
                        SimpleDateFormat yourDateFormat = new SimpleDateFormat("dd MMM yyyy · HH'h'mm", Locale.getDefault());
                        String dateString = simpleDateFormat.format(utcDate);
                        binding.orderdate.setText(dateString);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
    
Devesh Kumawat
  • 173
  • 1
  • 6