-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yongjingchuan
authored and
yongjingchuan
committed
Aug 19, 2020
1 parent
71000cc
commit d41da80
Showing
2 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/main/java/com/cy/generate/common/builder/DataSourceProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
67
src/main/java/com/cy/generate/common/transform/MyDateFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |