Skip to content

Commit

Permalink
modified
Browse files Browse the repository at this point in the history
  • Loading branch information
yongjingchuan authored and yongjingchuan committed Aug 19, 2020
1 parent 71000cc commit d41da80
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.cy.generate.common.builder;

import lombok.Data;

/**
* @Description:数据源属性文件
* @Author: YongJingChuan
* @Date: 2020/8/19 14:44
*/
@Data
public class DataSourceProperties {
private String driverClassName;
private String url;
private String username;
private String password;
private String dbpoolClass;
private String dbpoolMinimumIdle;
private String dbpoolMaximumPoolSize;
private String dbpoolMaxLifetime;
private String dbpoolConnectionTimeout;
private String dbpoolIdleTimeout;
private String wycdsSql;
private String wycdsJdbclog;
private String wycdsRangeCompare;
private String wycdsRoute2all;
private String wycdsWycpDecoding;
}
67 changes: 67 additions & 0 deletions src/main/java/com/cy/generate/common/transform/MyDateFormat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.cy.generate.common.transform;

import java.text.*;
import java.util.Date;

/**
* @Description:
* @Author: YongJingChuan
* @Date: 2020/8/19 14:42
*/
public class MyDateFormat extends DateFormat {
private DateFormat dateFormat;

private SimpleDateFormat format1 = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");

public MyDateFormat(DateFormat dateFormat) {
this.dateFormat = dateFormat;
}

@Override
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
return dateFormat.format(date, toAppendTo, fieldPosition);
}

@Override
public Date parse(String source, ParsePosition pos) {

Date date = null;

try {

date = format1.parse(source, pos);
} catch (Exception e) {

date = dateFormat.parse(source, pos);
}

return date;
}

// 主要还是装饰这个方法
@Override
public Date parse(String source) throws ParseException {

Date date = null;

try {

// 先按我的规则来
date = format1.parse(source);
} catch (Exception e) {

// 不行,那就按原先的规则吧
date = dateFormat.parse(source);
}

return date;
}

// 这里装饰clone方法的原因是因为clone方法在jackson中也有用到
@Override
public Object clone() {
Object format = dateFormat.clone();
return new MyDateFormat((DateFormat) format);
}

}

0 comments on commit d41da80

Please sign in to comment.