Added date formatting

This commit is contained in:
Robert Kolner committed 2011-10-19 21:33:35 +02:00
1 parent da89841001
commit 8aa1911bcb
4 files changed
+38 -29

No files matched your search

+12 -10
View File
@@ -1,15 +1,20 @@
package com.studentersamfundet.app;
import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Event implements Serializable {
private static final long serialVersionUID = 1L;
public static final String ALL = "Alle";
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
public int id;
public String title;
public String description;
public String date;
public Date date;
public String location;
public String text;
public String category;
@@ -25,21 +30,18 @@ public class Event implements Serializable {
this.id = id;
this.title = title.trim();
this.description = (description == null) ? "" : description.trim();
this.date = (date == null) ? "" : date.trim();
this.location = (location == null) ? "" : location.trim();
this.text = (text == null) ? "" : text.trim();
this.category = (category == null) ? "" : category.trim();
try {
this.date = (date == null) ? null : dateFormat.parse(date.trim());
} catch (ParseException e) {
this.date = null;
}
}
public String toString() {
return this.title;
}
public String getDateString() {
String date = this.date;
String month = date.substring(5, 7);
String day = date.substring(8, 10);
return Utils.stripNullFromDay(day) + ". " + Utils.intToMonthStr(Integer.parseInt(month));
}
}