package com.kidgrow.db.sharding;
|
|
import java.text.SimpleDateFormat;
|
import java.util.Date;
|
import java.util.Locale;
|
|
/**
|
* 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br>
|
*
|
* @Description: 按月分表后缀<br>
|
* @Project: <br>
|
* @CreateDate: Created in 2020/2/4 16:05 <br>
|
* @Author: <a href="4345453@kidgrow.com">liuke</a>
|
*/
|
public class MonthTableSuffix implements TableSuffix {
|
|
private Date date;
|
|
public MonthTableSuffix(Date date) {
|
if (date == null) {
|
throw new IllegalArgumentException("date should not be null");
|
}
|
this.date = date;
|
}
|
|
@Override
|
public String getSuffix() {
|
return String.format("_%s", createFormatter().format(date));
|
}
|
|
private static SimpleDateFormat createFormatter() {
|
return new SimpleDateFormat("yyyyMM", Locale.CHINA);
|
}
|
|
}
|