Skip to content

Commit f9cfa09

Browse files
emawbyJeasmine
authored andcommitted
move the iso8601 SimpleDateFormat to its own class
1 parent f4d8763 commit f9cfa09

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/OSInAppMessage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private Date parseEndTimeJson(JSONObject json) {
9696
return null;
9797
}
9898

99-
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
99+
SimpleDateFormat format = OneSignalSimpleDateFormat.iso8601Format();
100100
try {
101101
Date date = format.parse(endTimeString);
102102
return date;
@@ -179,7 +179,7 @@ JSONObject toJSONObject() {
179179
json.put(IAM_TRIGGERS, orConditions);
180180

181181
if (this.endTime != null) {
182-
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
182+
SimpleDateFormat format = OneSignalSimpleDateFormat.iso8601Format();
183183
String endTimeString = format.format(this.endTime);
184184
json.put(END_TIME, endTimeString);
185185
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Modified MIT License
3+
*
4+
* Copyright 2020 OneSignal
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* 1. The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* 2. All copies of substantial portions of the Software may only be used in connection
17+
* with services provided by OneSignal.
18+
*
19+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
* THE SOFTWARE.
26+
*/
27+
package com.onesignal;
28+
29+
import java.text.SimpleDateFormat;
30+
import java.util.Locale;
31+
32+
class OneSignalSimpleDateFormat {
33+
static SimpleDateFormat iso8601Format() {
34+
return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
35+
}
36+
}

0 commit comments

Comments
 (0)