]> iEval git - unical.git/commitdiff
Better date/time formatting
authorMarius Gavrilescu <marius@ieval.ro>
Wed, 21 Aug 2013 12:29:54 +0000 (15:29 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Wed, 21 Aug 2013 12:29:54 +0000 (15:29 +0300)
src/ro/ieval/unical/DisplayEventActivity.java
src/ro/ieval/unical/EventListActivity.java

index 0bff03217f7a9a15003b59b921548608e960063c..4f160696bd6f3cc5aee6a0496ba3d8bb60c37174 100644 (file)
@@ -1,5 +1,6 @@
 package ro.ieval.unical;
 
+import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Locale;
@@ -45,7 +46,7 @@ public class DisplayEventActivity extends Activity {
                                        final TextView date = (TextView) rowView.findViewById(R.id.alarm_datetime);
                                        final Button delete = (Button) rowView.findViewById(R.id.alarm_delete);
                                        delete.setOnClickListener(new DeleteListener(getItem(position)));
-                                       date.setText(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.UK).format(getItem(position)));
+                                       date.setText(DateFormat.getDateTimeInstance().format(getItem(position)));
 
                                        return rowView;
                                }
@@ -75,9 +76,9 @@ public class DisplayEventActivity extends Activity {
 
                final Date start=new Date(event.dtstart);
                final Date end=new Date(event.dtend);
-               final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.UK);
-               final SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss", Locale.UK);
-               final SimpleDateFormat dayOfWeekFormat = new SimpleDateFormat("EEEEEEE", Locale.UK);
+               final DateFormat dateFormat = DateFormat.getDateInstance();
+               final DateFormat timeFormat = DateFormat.getTimeInstance();
+               final DateFormat dayOfWeekFormat = new SimpleDateFormat("EEEEEEE", Locale.UK);
 
                startDay.setText(dayOfWeekFormat.format(start));
                if(!dateFormat.format(start).equals(dateFormat.format(end))) {
index 346178152de3da4fcb89fb7e5172d4b4f68e5f91..41b3cd7114492b80d939ecec95b9f95d7d593c79 100644 (file)
@@ -15,6 +15,7 @@ import android.widget.AdapterView;
 import android.widget.ArrayAdapter;
 import android.widget.ListView;
 import android.widget.TextView;
+import java.text.DateFormat;
 import java.util.Arrays;
 import java.util.Comparator;
 import java.util.Date;
@@ -45,10 +46,11 @@ public final class EventListActivity extends ListActivity {
                        final TextView dstart = (TextView) rowView.findViewById(R.id.smalldatestart);
                        final TextView dend = (TextView) rowView.findViewById(R.id.smalldateend);
                        final View header = rowView.findViewById(R.id.rowHeader);
+                       final DateFormat format = DateFormat.getDateTimeInstance();
                        header.setBackgroundColor(events[position].eventColour);
                        title.setText(events[position].title);
-                       dstart.setText(new Date(events[position].dtstart).toString());
-                       dend.setText(new Date(events[position].dtend).toString());
+                       dstart.setText(format.format(new Date(events[position].dtstart)));
+                       dend.setText(format.format(new Date(events[position].dtend)));
 
                        return rowView;
                }
This page took 0.029334 seconds and 4 git commands to generate.