androiddatetime

How to get Current Date and time of Dubai in Android?


I am getting current date of the device, but i want the date and time of city Dubai, Any one please help me in doing this.when the activity called the date and time should be displayed, Any help will be appriciated. thank you..


Solution

  • SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Date parsed = format.parse("2011-03-01 15:10:37");
    // => This time is in the user phone timezone, you will maybe need to turn it in UTC!
    TimeZone tz = TimeZone.getTimeZone("Asia/Dubai");
    format.setTimeZone(tz);
    
    String result = format.format(parsed);