首页新闻找找看学习计划

大佬们求教!!!

0
悬赏园豆:100 [已解决问题] 解决于 2019-06-20 12:32

我做这个模块的导入导出功能,想给时间format一下,但是不知道怎么写,
这是导入之前可以预览的方法:
/**

导入预览
@return
@throws Exception
*/
public String addExcelSocial() throws Exception {
path = ServletActionContext.getRequest().getRealPath("/leading");
String today=DateUtil.getTimeStamp();
fileFileName="Excel3_"+today+"."+"xls";
File destFile = new File(path, fileFileName);
OutputStream os = new FileOutputStream(destFile);
InputStream is = new FileInputStream(file);
byte[] buffer = new byte[1024];
int length = 0;
while(-1 != (length = is.read(buffer))){
os.write(buffer, 0, length);
}
is.close();
os.close();
String[] names = new String[] { "姓名", "身份证号","参保地","退伍证编号", "参保时间",
"录入时间","录入人员","修改时间","修改人员" };
LinkedHashMap<String, String> fieldMaps = new LinkedHashMap<String, String>();

fieldMaps.put("socialName", "姓名");
fieldMaps.put("socialIdNumber", "身份证号");
fieldMaps.put("socialAddress", "参保地");
fieldMaps.put("dischargeId", "退伍证编号");

fieldMaps.put("insuredTime", "参保时间");

fieldMaps.put("crateTime", "录入时间");
fieldMaps.put("entrypersonnel", "录入人员");
fieldMaps.put("modifyTime", "修改时间");
fieldMaps.put("modifyStaff", "修改人员");

List<Social> list = ExcelUitl.importoutSocial(destFile,names,fieldMaps);

List<Social> resultlist1 = new ArrayList<Social>();
List<Social> resultlist2 = new ArrayList<Social>();
List<Social> resultlist3 = new ArrayList<Social>();

for (Social sl : list) {

 if ("".equals(sl.getSocialName())
         || "".equals(sl.getSocialIdNumber())
         || sl.getSocialName() == null
         || sl.getSocialIdNumber()== null){
     resultlist1.add(sl);
 }
 List<Social> staa=socialService.getBySocialNme(sl.getSocialName());
     if(staa.size()> 0){
         resultlist2.add(sl);
     }
 List<Social> stm=socialService.getBySocialNumber(sl.getSocialIdNumber());
 if(stm.size()>0){
     resultlist3.add(sl);
 }

}
if (resultlist1.size() > 0) {
if (resultlist1.size() > 300) {
resultlist = resultlist1.subList(0, 300);
} else {
resultlist = resultlist1;
}
result_number = 1;
} else if (resultlist1.size() == 0 && resultlist2.size() > 0) {
if (resultlist2.size() > 300) {
resultlist = resultlist2.subList(0, 300);
} else {
resultlist = resultlist2;
}
result_number = 2;
}else if(resultlist1.size() == 0 && resultlist2.size() == 0 && resultlist3.size() > 0){
if (resultlist3.size() > 300) {
resultlist = resultlist3.subList(0, 300);
} else {
resultlist = resultlist3;
}
result_number = 3;
}else{

 if (list.size() > 300) {
     resultlist = list.subList(0, 300);
 } else {
     resultlist = list;
 }

 result_number = 4;

}

return "preview";
}

ppplum的主页 ppplum | 初学一级 | 园豆:3
提问于:2019-06-04 09:26
< >
分享
最佳答案
0

这样:

Date dtNow = new Date();
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String myDt = sdf1.format(dtNow.getTime());
System.out.println(myDt);

SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
myDt = sdf2.format(dtNow.getTime());
System.out.println(myDt);
收获园豆:100
三人乐乐 | 老鸟四级 |园豆:3180 | 2019-06-04 10:17

还是没解决大佬

ppplum | 园豆:3 (初学一级) | 2019-06-20 12:31
其他回答(2)
0

虽然我不会,但你看看这个能不能帮助到你。
https://www.cnblogs.com/kiwenzhang/p/10960742.html#4271020

YaTung | 园豆:202 (菜鸟二级) | 2019-06-04 09:58

虽然看了还是不会,但是谢谢你。

支持(0) 反对(0) ppplum | 园豆:3 (初学一级) | 2019-06-04 10:07
0

把时间转化成字符串呗,然后再写入到excel不就完事了

只会一点java | 园豆:211 (菜鸟二级) | 2019-06-10 09:25
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册