Skip to content

Commit

Permalink
タイムゾーンの設定漏れ
Browse files Browse the repository at this point in the history
  • Loading branch information
nemuzuka committed Jun 12, 2012
1 parent 813a48b commit 4f05648
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/main/java/jp/co/nemuzuka/utils/DateTimeUtils.java
Expand Up @@ -101,6 +101,7 @@ public static List<Date> getStartEndDate4SunDay(String targetYyyyMM) {
List<Date> list = getStartEndDate(targetYyyyMM);
Date startDate = list.get(0);
Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(getTimeZone());

//月初の設定
while(true) {
Expand Down Expand Up @@ -439,11 +440,19 @@ public static int calcAge(Date birthDay, Date baseDate) {
public static SimpleDateFormat createSdf(String pattern) {
SimpleDateFormat sdf = new SimpleDateFormat(pattern);

sdf.setTimeZone(getTimeZone());
return sdf;
}

/**
* タイムゾーン取得.
* @return ThreadLocalに設定されているタイムゾーン
*/
private static TimeZone getTimeZone() {
String timeZone = UserTimeZone.timeZone.get();
if(StringUtils.isEmpty(timeZone)) {
timeZone = jp.co.nemuzuka.common.TimeZone.GMT_P_9.getCode();
}
sdf.setTimeZone(TimeZone.getTimeZone(timeZone));
return sdf;
return TimeZone.getTimeZone(timeZone);
}
}

0 comments on commit 4f05648

Please sign in to comment.