I have a text view that should show date time as follows on it.
2018-04-25T12:40:15 IST
I tried with simple unit test in android studio, it print the exact result what i want
My Test Class
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
Date now = Calendar.getInstance().getTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss z");
sdf.setTimeZone(TimeZone.getDefault());
System.out.println(sdf.format(now) );
}
}
Output
2018-04-25T12:40:15 IST
But when I show it on a TextView in Activity it is showing something different as follows
2018-04-25T12:31:29 GMT+05:30
I don't know what mistake I have made, Can any one help me how to achieve. Also note IST is not static for all result, It should be dynamic depends on the users time zome.