Skip to content

Commit 2583bc1

Browse files
committed
change ReceiptInfo to a long timestamp instead of a Date object
1 parent dffaf54 commit 2583bc1

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ All notable changes to this project will be documented in this file.
66
### Added
77
- ProductNotFound events are now posted when a scanned product is not found
88

9+
### Changed
10+
- ReceiptInfo.getDate() is now deprecated, use getTimestamp instead.
11+
912
## [0.15.2]
1013

1114
### Changes

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ allprojects {
2323
}
2424

2525
project.ext {
26-
sdkVersion='0.15.2'
26+
sdkVersion='0.15.3'
2727
versionCode=1
2828

2929
compileSdkVersion=28

core/src/main/java/io/snabble/sdk/ReceiptInfo.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
public class ReceiptInfo {
66
private String id;
77
private String projectId;
8-
private Date date;
8+
private long timestamp;
99
private String pdfUrl;
1010
private String shopName;
1111
private String price;
1212

13-
public ReceiptInfo(String id, String projectId, Date date, String pdfUrl, String shopName, String price) {
13+
public ReceiptInfo(String id, String projectId, long timestamp, String pdfUrl, String shopName, String price) {
1414
this.id = id;
1515
this.projectId = projectId;
16-
this.date = date;
16+
this.timestamp = timestamp;
1717
this.pdfUrl = pdfUrl;
1818
this.shopName = shopName;
1919
this.price = price;
@@ -27,8 +27,13 @@ public String getProjectId() {
2727
return projectId;
2828
}
2929

30+
@Deprecated
3031
public Date getDate() {
31-
return date;
32+
return new Date(timestamp);
33+
}
34+
35+
public long getTimestamp() {
36+
return timestamp;
3237
}
3338

3439
public String getPdfUrl() {

core/src/main/java/io/snabble/sdk/ReceiptsApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void success(ApiReceipt apiReceipt) {
8787
ReceiptInfo receiptInfo = new ReceiptInfo(
8888
apiOrder.id,
8989
apiOrder.project,
90-
simpleDateFormat.parse(apiOrder.date),
90+
simpleDateFormat.parse(apiOrder.date).getTime(),
9191
snabble.absoluteUrl(apiLink.href),
9292
apiOrder.shopName,
9393
priceFormatter.format(apiOrder.price));

0 commit comments

Comments
 (0)