Skip to content

Commit d41da80

Browse files
yongjingchuanyongjingchuan
authored andcommitted
modified
1 parent 71000cc commit d41da80

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.cy.generate.common.builder;
2+
3+
import lombok.Data;
4+
5+
/**
6+
* @Description:数据源属性文件
7+
* @Author: YongJingChuan
8+
* @Date: 2020/8/19 14:44
9+
*/
10+
@Data
11+
public class DataSourceProperties {
12+
private String driverClassName;
13+
private String url;
14+
private String username;
15+
private String password;
16+
private String dbpoolClass;
17+
private String dbpoolMinimumIdle;
18+
private String dbpoolMaximumPoolSize;
19+
private String dbpoolMaxLifetime;
20+
private String dbpoolConnectionTimeout;
21+
private String dbpoolIdleTimeout;
22+
private String wycdsSql;
23+
private String wycdsJdbclog;
24+
private String wycdsRangeCompare;
25+
private String wycdsRoute2all;
26+
private String wycdsWycpDecoding;
27+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package com.cy.generate.common.transform;
2+
3+
import java.text.*;
4+
import java.util.Date;
5+
6+
/**
7+
* @Description:
8+
* @Author: YongJingChuan
9+
* @Date: 2020/8/19 14:42
10+
*/
11+
public class MyDateFormat extends DateFormat {
12+
private DateFormat dateFormat;
13+
14+
private SimpleDateFormat format1 = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
15+
16+
public MyDateFormat(DateFormat dateFormat) {
17+
this.dateFormat = dateFormat;
18+
}
19+
20+
@Override
21+
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
22+
return dateFormat.format(date, toAppendTo, fieldPosition);
23+
}
24+
25+
@Override
26+
public Date parse(String source, ParsePosition pos) {
27+
28+
Date date = null;
29+
30+
try {
31+
32+
date = format1.parse(source, pos);
33+
} catch (Exception e) {
34+
35+
date = dateFormat.parse(source, pos);
36+
}
37+
38+
return date;
39+
}
40+
41+
// 主要还是装饰这个方法
42+
@Override
43+
public Date parse(String source) throws ParseException {
44+
45+
Date date = null;
46+
47+
try {
48+
49+
// 先按我的规则来
50+
date = format1.parse(source);
51+
} catch (Exception e) {
52+
53+
// 不行,那就按原先的规则吧
54+
date = dateFormat.parse(source);
55+
}
56+
57+
return date;
58+
}
59+
60+
// 这里装饰clone方法的原因是因为clone方法在jackson中也有用到
61+
@Override
62+
public Object clone() {
63+
Object format = dateFormat.clone();
64+
return new MyDateFormat((DateFormat) format);
65+
}
66+
67+
}

0 commit comments

Comments
 (0)