Skip to content

Commit ee7df8b

Browse files
committed
feat: YearMonthAttributeConverter 추가
1 parent 52dbf4b commit ee7df8b

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.loopers.infrastructure.converter;
2+
3+
import jakarta.persistence.AttributeConverter;
4+
import jakarta.persistence.Converter;
5+
6+
import java.time.YearMonth;
7+
8+
@Converter(autoApply = true)
9+
public class YearMonthAttributeConverter implements AttributeConverter<YearMonth, String> {
10+
11+
@Override
12+
public String convertToDatabaseColumn(YearMonth attribute) {
13+
return attribute != null ? attribute.toString() : null;
14+
}
15+
16+
@Override
17+
public YearMonth convertToEntityAttribute(String dbData) {
18+
return dbData != null ? YearMonth.parse(dbData) : null;
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.loopers.infrastructure.converter;
2+
3+
import jakarta.persistence.AttributeConverter;
4+
import jakarta.persistence.Converter;
5+
6+
import java.time.YearMonth;
7+
8+
@Converter(autoApply = true)
9+
public class YearMonthAttributeConverter implements AttributeConverter<YearMonth, String> {
10+
11+
@Override
12+
public String convertToDatabaseColumn(YearMonth attribute) {
13+
return attribute != null ? attribute.toString() : null; // "yyyy-MM"
14+
}
15+
16+
@Override
17+
public YearMonth convertToEntityAttribute(String dbData) {
18+
return dbData != null ? YearMonth.parse(dbData) : null;
19+
}
20+
}

0 commit comments

Comments
 (0)