~plaxx/tomdroid/iteration-3

« back to all changes in this revision

Viewing changes to src/org/tomdroid/Note.java

  • Committer: Olivier Bilodeau
  • Date: 2008-12-11 05:51:16 UTC
  • Revision ID: olivier@bottomlesspit.org-20081211055116-jaz6p38jevb0lz1x
Parsing title and last-change-date tags in Note XML and setting them in Note object.
last-change-date is parsed using joda-time lib (jar added to lib/)

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
import javax.xml.parsers.SAXParser;
31
31
import javax.xml.parsers.SAXParserFactory;
32
32
 
 
33
import org.joda.time.DateTime;
 
34
import org.joda.time.format.DateTimeFormatter;
 
35
import org.joda.time.format.ISODateTimeFormat;
33
36
import org.tomdroid.dao.net.NoteDAO;
34
37
import org.tomdroid.dao.net.NoteDAOImpl;
35
38
import org.tomdroid.xml.NoteHandler;
63
66
        private SpannableStringBuilder noteContent = new SpannableStringBuilder();
64
67
        private String url;
65
68
        private String title;
66
 
        private Date lastChangeDate;
 
69
        private DateTime lastChangeDate;
67
70
        
68
71
        // Handles async state
69
72
        private Handler parentHandler;
94
97
                this.title = title;
95
98
        }
96
99
 
97
 
        public Date getLastChangeDate() {
 
100
        public DateTime getLastChangeDate() {
98
101
                return lastChangeDate;
99
102
        }
100
103
 
101
 
        public void setLastChangeDate(Date lastChangeDate) {
 
104
        public void setLastChangeDate(DateTime lastChangeDate) {
102
105
                this.lastChangeDate = lastChangeDate;
103
106
        }
104
107
 
188
191
                parentHandler.sendEmptyMessage(NOTE_RECEIVED_AND_VALID);
189
192
 
190
193
    }
 
194
 
 
195
        @Override
 
196
        public String toString() {
 
197
                // format date time according to XML standard
 
198
                DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
 
199
                return new String("Note: "+ getTitle() + " (" + fmt.print(getLastChangeDate()) + ")");
 
200
        }
191
201
        
192
202
}