File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
StudyplusAndroidSDK/src/main/java/jp/studyplus/android/sdk/service/studyrecord Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 3
3
import com .google .common .base .Optional ;
4
4
5
5
import java .text .SimpleDateFormat ;
6
- import java .util .Date ;
6
+ import java .util .Calendar ;
7
+ import java .util .GregorianCalendar ;
7
8
import java .util .Locale ;
9
+ import java .util .TimeZone ;
8
10
9
11
public class StudyRecordBuilder {
10
12
@@ -33,15 +35,18 @@ public StudyRecordBuilder setDurationSeconds(int seconds){
33
35
return this ;
34
36
}
35
37
36
- public StudyRecordBuilder setRecordedTime (Date date ){
37
- String time = new SimpleDateFormat ("yyyy'-'MM'-'dd' 'HH':'mm':'ss" , Locale .US ).format (date );
38
+ public StudyRecordBuilder setRecordedTime (Calendar calendar ){
39
+ SimpleDateFormat format = new SimpleDateFormat ("yyyy'-'MM'-'dd' 'HH':'mm':'ss" , Locale .US );
40
+ format .setTimeZone (calendar .getTimeZone ());
41
+ String time = format .format (calendar .getTime ());
38
42
this .recordedTime = Optional .of (time );
39
43
return this ;
40
44
}
41
45
42
46
public StudyRecordSnapshot build (){
43
47
if (!recordedTime .isPresent ()){
44
- setRecordedTime (new Date ());
48
+ Calendar current = new GregorianCalendar (TimeZone .getTimeZone ("UTC" ), Locale .US );
49
+ setRecordedTime (current );
45
50
}
46
51
if (!comment .isPresent ()){
47
52
setComment ("" );
You can’t perform that action at this time.
0 commit comments