I am new to java and i am making a weather app.
I am getting data from openweathermap server in JSON format. Below is the format
"sys":{
"type":1,
"id":7758,
"message":0.2194,
"country":"India",
"sunrise":1410569741,
"sunset":1410614119
},
I want to extract sunrise and sunset from it but what i want is only time and not date. Below is my code
DateFormat df = DateFormat.getDateTimeInstance();
String sunrise= df.format(new Date(json.getJSONObject("sys").getLong("sunrise")*1000).getTime());
String sunset = df.format(new Date(json.getJSONObject("sys").getLong("sunset")*1000).getTime());
Problem with my code is that it is giving me both time and date and output is " Sep 13, 2014 6:25:41 AM" for sunrise. Similar is for sunset. ?
How shall i extract "6:25:41 AM" it? I only want time and not year/month/day