File tree Expand file tree Collapse file tree
StudyplusAndroidSDK/src/main/java/jp/studyplus/android/sdk/service/studyrecord Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import com .google .common .base .Optional ;
44
55import java .text .SimpleDateFormat ;
6- import java .util .Date ;
6+ import java .util .Calendar ;
7+ import java .util .GregorianCalendar ;
78import java .util .Locale ;
9+ import java .util .TimeZone ;
810
911public class StudyRecordBuilder {
1012
@@ -33,15 +35,18 @@ public StudyRecordBuilder setDurationSeconds(int seconds){
3335 return this ;
3436 }
3537
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 ());
3842 this .recordedTime = Optional .of (time );
3943 return this ;
4044 }
4145
4246 public StudyRecordSnapshot build (){
4347 if (!recordedTime .isPresent ()){
44- setRecordedTime (new Date ());
48+ Calendar current = new GregorianCalendar (TimeZone .getTimeZone ("UTC" ), Locale .US );
49+ setRecordedTime (current );
4550 }
4651 if (!comment .isPresent ()){
4752 setComment ("" );
You can’t perform that action at this time.
0 commit comments