0

i get the phone default time and trying to convert it to colombo time this is my code

Calendar c = Calendar.getInstance();

        SimpleDateFormat currFormat = new SimpleDateFormat(
                "EEE MMM dd HH:mm:ss zzz yyyy");

    currFormat.setTimeZone(TimeZone.getTimeZone("Asia/Colombo"));

        try {
            c.setTime(currFormat.parse(c.getTime().toString()));
        } catch (ParseException e1) {
            // TODO Auto-generated catch block
            Log.e("Time In Srvice", e1.getMessage());
            e1.printStackTrace();
        }

Code is working fine but time is not converting to the colombo time zone

Kamal Upasena
  • 1,329
  • 4
  • 13
  • 38
  • Check with http://developer.android.com/reference/java/util/TimeZone.html#getAvailableIDs() if Asia/Columbo is a valid zone – Stefan de Bruijn Aug 23 '13 at 07:43
  • refer [here](http://stackoverflow.com/a/6094475/2345913) – CRUSADER Aug 23 '13 at 07:45
  • Crusader that works and i getting a string like this "Fri Aug 23 14:46:39 IST 2013" but when i am trying to convert that in to date time i am getting a different value any idea why is that – Kamal Upasena Aug 23 '13 at 09:18

1 Answers1

0

What you want to achieve is not totally clear but it looks like all you need to do is to use the setTimeZone() method of the Calendar class instance itself, instead of going through this set/get.

Arnaud Quillaud
  • 4,420
  • 1
  • 12
  • 8