public View getView(int position, View convertView, ViewGroup parent){
View listItemView = convertView;
if (listItemView == null){
listItemView = LayoutInflater.from(getContext()).inflate(
R.layout.earthquake_list_item, parent, false);
}
Earthquake currentEarthquake = getItem(position);
TextView magnitudeView = (TextView) listItemView.findViewById(R.id.magnitude);
magnitudeView.setText(currentEarthquake.getMagnitude());
TextView locaionView = (TextView) listItemView.findViewById(R.id.location);
locationView.setText(currentEarthquake.getLocation());
Date dateObject = new Date(currentEarthquake.getTimeInMilliseconds());
TextView dateView = (TextView) listItemView.findViewById(R.id.date);
String formattedDate = formatDate(dateObject);
dateView.setText(formattedDate);
TextView timeView = (TextView) listItemView.findViewById(R.id.time);
String formattedTime = formatTime(dateObject);
timeView.setText(formattedTime);
return listItemView;
}
private String formatDate(Date dateObject){
SimpleDateFormat dateFormat = new SimpleDateFormat("LLL dd, yyyy");
return dateFormat.format(dateObject);
}
private String formatTime(Date deteObject){
SimpleDateFormat timeFormat = new SimpleDateFormat("h:mm a");
return timeFormat.format(dateObject);
}