I am new to Android and I am currently facing an issue to get current time given the timezone.
I get timezone in the format \"GMT-7\" i.e. string. and I have the sys
Set the timezone to formatter, not calendar:
public String getTime(String timezone) {
Calendar c = Calendar.getInstance();
Date date = c.getTime(); //current date and time in UTC
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
df.setTimeZone(TimeZone.getTimeZone(timezone)); //format in given timezone
String strDate = df.format(date);
return strDate;
}