工作组导入导出
This commit is contained in:
+2
-1
@@ -94,7 +94,8 @@ public class ExcelImportUtilByWk {
|
||||
cell = row.getCell(a);
|
||||
if (null!=mapExcel.get(a).exportFormat() && !"".equals(mapExcel.get(a).exportFormat())) {
|
||||
String value = convertCellValueToString(cell);
|
||||
Date date= DateUtils.stringToDate(value,mapExcel.get(a).exportFormat());
|
||||
Date date= DateUtils.stringToDate(TrainFormDate.dealWithTimeZoneyyyy(value,mapExcel.get(a).exportFormat()),mapExcel.get(a).exportFormat());
|
||||
// Date date= DateUtils.stringToDate(value,mapExcel.get(a).exportFormat());
|
||||
map.get(a).set(o, date);
|
||||
}else {
|
||||
String value = convertCellValueToString(cell);
|
||||
|
||||
@@ -71,41 +71,48 @@ public class TrainFormDate {
|
||||
time = time.replace("年", "-");
|
||||
time = time.replace("月", "-");
|
||||
time = time.replace("日", "");
|
||||
time = time.replace(" ", "");
|
||||
String times="";
|
||||
String[] da=time.split("-");
|
||||
for (String s:da) {
|
||||
if (s.trim().length()==1){
|
||||
s="0"+s;
|
||||
}
|
||||
times+=s+"-";
|
||||
}
|
||||
times=times.trim().substring(0,times.length()-1);
|
||||
Pattern p = Pattern.compile("^(?:(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\\/|-|\\.)(?:0?2\\1(?:29))$)|(?:(?:1[6-9]|[2-9]\\d)?\\d{2})(\\/|-|\\.)(?:(?:(?:0?[13578]|1[02])\\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\\2(?:0?[1-9]|1\\d|2[0-8]))$");
|
||||
if (p.matcher(times).matches()) {
|
||||
return times;
|
||||
} else {
|
||||
DateFormat formate2 = new SimpleDateFormat("EEEMMMddHH:mm:sszzzyyyy", Locale.ENGLISH);
|
||||
try{
|
||||
Date date = null;
|
||||
try {
|
||||
date = formate2.parse(time);
|
||||
String dateString = formate1.format(date);
|
||||
return dateString;
|
||||
} catch (ParseException e1) {
|
||||
try {
|
||||
int days = Integer.parseInt(time);
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.set(1900, 0, 1);
|
||||
c.add(Calendar.DATE, days - 2);
|
||||
Date realdate = c.getTime();
|
||||
String realday = formate1.format(realdate);
|
||||
return realday;
|
||||
}
|
||||
catch (Exception e2){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
date = formate1.parse(time);
|
||||
String success=formate1.format(date);
|
||||
|
||||
return success;
|
||||
}catch (Exception e) {
|
||||
time = time.replace(" ", "");
|
||||
String times = "";
|
||||
String[] da = time.split("-");
|
||||
for (String s : da) {
|
||||
if (s.trim().length() == 1) {
|
||||
s = "0" + s;
|
||||
}
|
||||
times += s + "-";
|
||||
}
|
||||
times = times.trim().substring(0, times.length() - 1);
|
||||
Pattern p = Pattern.compile("^(?:(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\\/|-|\\.)(?:0?2\\1(?:29))$)|(?:(?:1[6-9]|[2-9]\\d)?\\d{2})(\\/|-|\\.)(?:(?:(?:0?[13578]|1[02])\\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\\2(?:0?[1-9]|1\\d|2[0-8]))$");
|
||||
if (p.matcher(times).matches()) {
|
||||
return times;
|
||||
} else {
|
||||
DateFormat formate2 = new SimpleDateFormat("EEEMMMddHH:mm:sszzzyyyy", Locale.ENGLISH);
|
||||
Date date = null;
|
||||
try {
|
||||
date = formate2.parse(time);
|
||||
String dateString = formate1.format(date);
|
||||
return dateString;
|
||||
} catch (ParseException e1) {
|
||||
try {
|
||||
int days = Integer.parseInt(time);
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.set(1900, 0, 1);
|
||||
c.add(Calendar.DATE, days - 2);
|
||||
Date realdate = c.getTime();
|
||||
String realday = formate1.format(realdate);
|
||||
return realday;
|
||||
} catch (Exception e2) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user