I am trying to convert UTC time to local time.
UTC Time : 1465389050
I tried below code.But it is not printing or showing the result.So I am not sure this code will work or not.
MainActivity.java:
String created = "1465389050";
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
try {
Date myDate = simpleDateFormat.parse(created);
Log.e("myDate", ""+myDate);
Toast.makeText(getApplicationContext(), myDate.toString(), Toast.LENGTH_LONG).show();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}