誰かが私のスクリプトでタイムスタンプを日付に変換するのを手伝ってくれますか? 私はリストビューを取得し、リストビューは今日、昨日、前日、昨日正しくロードされます。タイムスタンプコードしか取得できなかったのは何日ですか?
これは私のメインクラスです:
if(_hasConnection()){
dataList.clear();
System.out.println("Start loading JSON");
JSONArray json = JSONFunctions.getJSONfromURL(Config.DOMAIN + "/report.php?category="+getCategory()+"&image=" + Config.IMAGE_WIDTH + "x" + Config.IMAGE_HEIGHT + "&id=1&date=1&limit=" + Config.LIMIT);
System.out.println("End loading JSON");
for (int i = 0; i < json.length(); i++) {
try {
JSONObject row = json.getJSONObject(i);
HashMap<String, String> map = new HashMap<String, String>();
map.put("id", row.getString("id"));
map.put("title", row.getString("title"));
map.put("image", row.getString("image"));
map.put("date", row.getString("date"));
dataList.add(map);
} catch (JSONException e) {
e.printStackTrace();
}
}
System.out.println("End putting in dataList");
adapter.reset();
int continueI = 0;
for (int i = 0; i < dataList.size(); i++) {
if(i > continueI) {
int daysAgo = Utils.daysAgo(dataList.get(i).get("date"));
//System.out.println("T: " + dataList.get(i).get("title") + " is daysAgo: " + daysAgo);
ArrayList<HashMap<String, String>> objects = new ArrayList<HashMap<String, String>>();
for (int q = 0; q < dataList.size(); q++) {
int daysAgoCompare = Utils.daysAgo(dataList.get(q).get("date"));
if(daysAgo == daysAgoCompare) {
objects.add(dataList.get(q));
continueI = q;
}
}
if(objects.size() > 0) {
String dayNaming;
if(daysAgo == 0) {
dayNaming = getString(R.string.today);
}else if(daysAgo == 1) {
dayNaming = getString(R.string.yesterday);
}
else if(daysAgo == 2) {
dayNaming = getString(R.string.day_before_yesterday);
}
else
{
//SimpleDateFormat dateformatddMMMM = new SimpleDateFormat("dd/MM/yyyy");
dayNaming = String.valueOf(dataList.get(i).get("date")); // new StringBuilder( dateformatddMMMM.format( new Date(Long.parseLong() * 10) ) ).toString();
}
//System.out.println("T: " + dayNaming + " is added");
adapter.addSection(dayNaming, new LazyAdapter(getApplicationContext(), Main.this, objects));
//adapter.addSection(dayNaming, new ArrayAdapter<String>(Main.this, R.layout.list_item, objects));
}