Skip to content

Commit

Permalink
Merge pull request #68 from backendoori/feature-server-timezone
Browse files Browse the repository at this point in the history
🚀 API 서버 타임 존 설정
  • Loading branch information
Sehee-Lee-01 authored Jan 12, 2024
2 parents eb61689 + dd94d85 commit abbf7f0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/java/com/backendoori/ootw/OotwApplication.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.backendoori.ootw;

import java.util.TimeZone;
import jakarta.annotation.PostConstruct;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
Expand All @@ -8,8 +10,15 @@
@ConfigurationPropertiesScan
public class OotwApplication {

public static final String TIMEZONE = "Asia/Seoul";

public static void main(String[] args) {
SpringApplication.run(OotwApplication.class, args);
}

@PostConstruct
public void setTimezone() {
TimeZone.setDefault(TimeZone.getTimeZone(TIMEZONE));
}

}
12 changes: 12 additions & 0 deletions src/test/java/com/backendoori/ootw/OotwApplicationTests.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.backendoori.ootw;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNoException;

import java.util.TimeZone;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand All @@ -23,4 +25,14 @@ void testMain() {
assertThatNoException().isThrownBy(main);
}

@DisplayName("애플리케이션을 지정된 Tiemzone으로 설정한다")
@Test
void testServerTimezone() {
// given // when
String id = TimeZone.getDefault().getID();

// then
assertThat(id).isEqualTo(OotwApplication.TIMEZONE);
}

}

0 comments on commit abbf7f0

Please sign in to comment.