Skip to content

Commit

Permalink
Documentation update on DateTimeConverter sample (#442)
Browse files Browse the repository at this point in the history
  • Loading branch information
cassioseffrin authored Dec 19, 2020
1 parent 9da21f3 commit dc871d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -584,12 +584,14 @@ The implementation and usage of the mentioned `DateTime` to `int` converter is d
class DateTimeConverter extends TypeConverter<DateTime, int> {
@override
DateTime decode(int databaseValue) {
return DateTime.fromMillisecondsSinceEpoch(databaseValue);
return databaseValue == null
? null
: DateTime.fromMillisecondsSinceEpoch(databaseValue);
}
@override
int encode(DateTime value) {
return value.millisecondsSinceEpoch;
return value == null ? null : value.millisecondsSinceEpoch;
}
}
```
Expand Down
6 changes: 4 additions & 2 deletions floor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -584,12 +584,14 @@ The implementation and usage of the mentioned `DateTime` to `int` converter is d
class DateTimeConverter extends TypeConverter<DateTime, int> {
@override
DateTime decode(int databaseValue) {
return DateTime.fromMillisecondsSinceEpoch(databaseValue);
return databaseValue == null
? null
: DateTime.fromMillisecondsSinceEpoch(databaseValue);
}
@override
int encode(DateTime value) {
return value.millisecondsSinceEpoch;
return value == null ? null : value.millisecondsSinceEpoch;
}
}
```
Expand Down

0 comments on commit dc871d6

Please sign in to comment.