Skip to content

Commit 8043566

Browse files
committed
Update Property.java
1 parent ae53a57 commit 8043566

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

src/net/tsz/afinal/db/table/Property.java

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,12 @@
1515
*/
1616
package net.tsz.afinal.db.table;
1717

18-
import android.annotation.SuppressLint;
1918
import java.lang.reflect.Field;
20-
import java.lang.reflect.InvocationTargetException;
2119
import java.lang.reflect.Method;
22-
import java.text.ParseException;
23-
import java.text.SimpleDateFormat;
2420
import java.util.Date;
2521

22+
import net.tsz.afinal.utils.FieldUtils;
23+
2624
/**
2725
* @title 属性
2826
* @description 【非主键】的【基本数据类型】 都是属性
@@ -55,7 +53,7 @@ public void setValue(Object receiver , Object value){
5553
} else if (dataType == long.class || dataType == Long.class) {
5654
set.invoke(receiver, value == null ? (Long) null: Long.parseLong(value.toString()));
5755
} else if (dataType == java.util.Date.class || dataType == java.sql.Date.class) {
58-
set.invoke(receiver, value == null ? (Date) null: stringToDateTime(value.toString()));
56+
set.invoke(receiver, value == null ? (Date) null: FieldUtils.stringToDateTime(value.toString()));
5957
} else if (dataType == boolean.class || dataType == Boolean.class) {
6058
set.invoke(receiver, value == null ? (Boolean) null: "1".equals(value.toString()));
6159
} else {
@@ -85,24 +83,7 @@ public <T> T getValue(Object obj){
8583
if(obj != null && get != null) {
8684
try {
8785
return (T)get.invoke(obj);
88-
} catch (IllegalArgumentException e) {
89-
e.printStackTrace();
90-
} catch (IllegalAccessException e) {
91-
e.printStackTrace();
92-
} catch (InvocationTargetException e) {
93-
e.printStackTrace();
94-
}
95-
}
96-
return null;
97-
}
98-
99-
@SuppressLint("SimpleDateFormat")
100-
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
101-
private static Date stringToDateTime(String strDate) {
102-
if (strDate != null) {
103-
try {
104-
return sdf.parse(strDate);
105-
} catch (ParseException e) {
86+
} catch (Exception e) {
10687
e.printStackTrace();
10788
}
10889
}

0 commit comments

Comments
 (0)