I am calling current weather API response from https://openweathermap.org/current
The API response has sunset and sunrise value like this : "sunrise": 1560343627, "sunset": 1560396563 The parameter unit is written as Sunset time, Unix, UTC
I know the location and now I want to convert this time to the local time of the place. How can I do it?
For converting timestamp to current time
Calendar calendar = Calendar.getInstance();
TimeZone tz = TimeZone.getDefault();
calendar.add(Calendar.MILLISECOND, tz.getOffset(calendar.getTimeInMillis()));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
java.util.Date currenTimeZone=new java.util.Date((long)1379487711*1000);
Toast.makeText(TimeStampChkActivity.this, sdf.format(currenTimeZone), Toast.LENGTH_SHORT).show();
Hope it will work
Thankew! Happy coding!