格式化日期-美國時間格式


import org.joda.time.DateTime;

import java.util.Date;

 public void setCreatedDate(Date createdDate) {

  this.createdDate = createdDate;
 }

 public void setCreatedDate(final DateTime createdDate) {

  this.createdDate = null == createdDate ? null : createdDate.toDate();
 }

 public DateTime getLastModifiedDate() {

  return null == lastModifiedDate ? null : new DateTime(lastModifiedDate);
 }

 

 public DateTime getCreatedDate() {

  return null == createdDate ? null : new DateTime(createdDate);
 }

 

public String getCreateDateStr() {
  if (serviceRequest != null && serviceRequest.getCreatedDate() != null) {
   SimpleDateFormat myFormatter = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss");
   createDateStr = myFormatter.format(serviceRequest.getCreatedDate().toDate()); //把DateTime類型轉換為Date類型
  }
  return createDateStr;
 }

 

在feedbackList.jspx頁面輸入日期:

<td>${feedback.createDateStr}</td> 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM