发表于: 2018-04-01 15:09:01

1 396


今天完成的事情:

 格式转换

package com.POJO;

import java.text.SimpleDateFormat;

public class DateToLong{
private Integer ID;
   private String create_at;
   private String update_at;
   private String name;
   private String dailyLink;
   private int QQ;
   private String onlineNumber;
   private String mail;
   private int phone;
   private String enrollmentTime;
   private String professionType;
   private String brotherName;
   private String promise;
   
   
   public void setID(Integer ID) {
this.ID = ID;
   }

public void setName(String name) {
this.name = name;
   }

public void setCreate_at(String create_at) {
this.create_at = create_at;
   }

public void setUpdate_at(String update_at) {
this.update_at = update_at;
   }

public void setDailyLink(String dailyLink) {
this.dailyLink = dailyLink;
   }

public void setQQ(int QQ) {
this.QQ = QQ;
   }

public void setOnlineNumber(String onlineNumber) {
this.onlineNumber = onlineNumber;
   }

public void setMail(String mail) {
this.mail = mail;
   }

public void setPhone(int phone) {
this.phone = phone;
   }

public void setEnrollmentTime(String enrollmentTime) {
this.enrollmentTime = enrollmentTime;
   }

public void setProfessionType(String professionType) {
this.professionType = professionType;
   }

public void setBrotherName(String brotherName) {
this.brotherName = brotherName;
   }

public void setPromise(String promise) {
this.promise = promise;
   }

@Override
   public String toString() {
return "Student{" +
"ID=" + ID +
", name='" + name + '\'' +
", QQ=" + QQ +
", onlineNumber='" + onlineNumber + '\'' +
", enrollmentTime=" + enrollmentTime +
", professionType='" + professionType + '\'' +
", dailyLink='" + dailyLink + '\'' +
", promise='" + promise + '\'' +
", brotherName='" + brotherName + '\'' +
", create_at=" + create_at +
", update_at=" + update_at +
'}';
   }
public static DateToLong dateToLong(Student stu) {
DateToLong myFmt = new DateToLong();
       myFmt.setID(stu.getID());
       myFmt.setName(stu.getName());
       myFmt.setQQ(stu.getQQ());
       myFmt.setBrotherName(stu.getBrotherName());
       myFmt.setDailyLink(stu.getDailyLink());
       myFmt.setPromise(stu.getPromise());
       myFmt.setMail(stu.getMail());
       myFmt.setPhone(stu.getPhone());
       //毕业时间类型转换
       SimpleDateFormat st = new SimpleDateFormat("yyyy年MM月dd日");
       String stchange = st.format(stu.getEnrollmentTime());
       myFmt.setEnrollmentTime(stchange);
//        Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(temp);
//        String str = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
       //创建时间类型转换
       SimpleDateFormat ct = new SimpleDateFormat("yyyy-MM-dd");
       String ctchange = ct.format(stu.getCreate_at());
       myFmt.setCreate_at(ctchange);
       //更新时间类型转换
       SimpleDateFormat ut = new SimpleDateFormat("yyyy-MM-dd");
       String utchange = ut.format(stu.getUpdate_at());
       myFmt.setUpdate_at(utchange);
       return myFmt;
   }
}

@RequestMapping(value = "/list",method = RequestMethod.GET)
public String select( Integer ID, Model model) throws Exception {
student = studentMapper.findUserById(ID);
   System.out.println(student);
   DateToLong newstu = DateToLong.dateToLong(student);
   System.out.println(newstu);
   model.addAttribute("student", newstu);
   return "list";
}


明天计划的事情:

完成整个列表日期转换格式
遇到的问题:

 
收获:


返回列表 返回列表
评论

    分享到