Skip to content

Commit

Permalink
updated sample to use Date object for timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
emilsjolander committed Dec 27, 2013
1 parent 338c466 commit 0fba2a4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=1.1.1-SNAPSHOT
VERSION_NAME=1.1.1
GROUP=se.emilsjolander

POM_DESCRIPTION=Sprinkles is a boiler-plate-reduction-library for dealing with databases in android applications
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import android.widget.TextView;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import se.emilsjolander.sprinkles.models.Note;
Expand Down Expand Up @@ -40,7 +39,7 @@ protected void onCreate(Bundle savedInstanceState) {
noteContent.setText(mNote.getContent());

if (mNote.exists()) {
String updatedAtString = new SimpleDateFormat("HH:mm EEEE", Locale.getDefault()).format(new Date(mNote.getUpdatedAt()));
String updatedAtString = new SimpleDateFormat("HH:mm EEEE", Locale.getDefault()).format(mNote.getUpdatedAt());
lastUpdatedAt.setText(getString(R.string.last_updated, updatedAtString));
} else {
lastUpdatedAt.setVisibility(View.GONE);
Expand Down
14 changes: 8 additions & 6 deletions sample/src/se/emilsjolander/sprinkles/models/Note.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package se.emilsjolander.sprinkles.models;

import java.util.Date;

import se.emilsjolander.sprinkles.Model;
import se.emilsjolander.sprinkles.annotations.AutoIncrementPrimaryKey;
import se.emilsjolander.sprinkles.annotations.Column;
Expand All @@ -13,8 +15,8 @@ public class Note extends Model {
@Column("id") private long id;

@Column("content") private String content;
@Column("created_at") private long createdAt;
@Column("updated_at") private long updatedAt;
@Column("created_at") private Date createdAt;
@Column("updated_at") private Date updatedAt;
@DynamicColumn("tag_count") private int tagCount;

public long getId() {
Expand All @@ -29,11 +31,11 @@ public void setContent(String content) {
this.content = content;
}

public long getCreatedAt() {
public Date getCreatedAt() {
return createdAt;
}

public long getUpdatedAt() {
public Date getUpdatedAt() {
return updatedAt;
}

Expand All @@ -44,13 +46,13 @@ public int getTagCount() {
@Override
protected void beforeCreate() {
super.beforeCreate();
createdAt = System.currentTimeMillis();
createdAt = new Date();
}

@Override
protected void beforeSave() {
super.beforeSave();
updatedAt = System.currentTimeMillis();
updatedAt = new Date();
}

}

0 comments on commit 0fba2a4

Please sign in to comment.