我正在向现有项目添加ORMLite,所以我已经有了一个数据库,这是我的班级:
@DatabaseTable(tableName = "demandes")
public class Demandes {
public static final String TABLE_DEMANDES = "demandes";
public static final String KEY_ID = "id";
public static final String KEY_XML_SENDLEAD = "xmlSendLead";
public static final String KEY_STATUTENVOIE_SENDLEAD = "statutEnvoieSendLead";
public static final String KEY_DATEENVOIE_SENDLEAD = "dateEnvoieSendLead";
public static final String KEY_CONTACTWEBID = "contactWebId";
public static final String KEY_XML_SIMULATION = "xmlSimulation";
public static final String KEY_STATUTENVOIE_SIMULATION = "statutEnvoieSimulation";
public static final String KEY_DATEENVOIE_SIMULATION = "dateEnvoieSimulation";
@DatabaseField(generatedId = true, allowGeneratedIdInsert = true,columnName = KEY_ID)
private int id;
@DatabaseField(columnName = KEY_XML_SENDLEAD)
private String xmlSendLead;
@DatabaseField(columnName = KEY_STATUTENVOIE_SENDLEAD)
private int statutEnvoieSendLead;
@DatabaseField(columnName = KEY_DATEENVOIE_SENDLEAD, dataType = DataType.DATE_STRING, format = "yyyy-MM-dd HH:mm:ss")
private Date dateEnvoieSendLead;
@DatabaseField(columnName = KEY_CONTACTWEBID)
private int contactWebId;
@DatabaseField(columnName = KEY_XML_SIMULATION)
private String xmlSimulation;
@DatabaseField(columnName = KEY_STATUTENVOIE_SIMULATION)
private int statutEnvoieSimulation;
@DatabaseField(columnName = KEY_DATEENVOIE_SIMULATION, dataType = DataType.DATE_STRING, format = "yyyy-MM-dd HH:mm:ss")
private Date dateEnvoieSimulation;
public Demandes() {
}
public Demandes(String xmlSendLead, int statutEnvoieSendLead, Date dateEnvoieSendLead, int contactWebId, String xmlSimulation, int statutEnvoieSimulation, Date dateEnvoieSimulation) {
this.xmlSendLead = xmlSendLead;
this.statutEnvoieSendLead = statutEnvoieSendLead;
this.dateEnvoieSendLead = dateEnvoieSendLead;
this.contactWebId = contactWebId;
this.xmlSimulation = xmlSimulation;
this.statutEnvoieSimulation = statutEnvoieSimulation;
this.dateEnvoieSimulation = dateEnvoieSimulation;
}
public Demandes(int id, String xmlSendLead, int statutEnvoieSendLead, Date dateEnvoieSendLead, int contactWebId, String xmlSimulation, int statutEnvoieSimulation, Date dateEnvoieSimulation) {
this.id = id;
this.xmlSendLead = xmlSendLead;
this.statutEnvoieSendLead = statutEnvoieSendLead;
this.dateEnvoieSendLead = dateEnvoieSendLead;
this.contactWebId = contactWebId;
this.xmlSimulation = xmlSimulation;
this.statutEnvoieSimulation = statutEnvoieSimulation;
this.dateEnvoieSimulation = dateEnvoieSimulation;
}
public Date getDateEnvoieSimulation() {
return dateEnvoieSimulation;
}
public void setDateEnvoieSimulation(Date dateEnvoieSimulation) {
this.dateEnvoieSimulation = dateEnvoieSimulation;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getXmlSendLead() {
return xmlSendLead;
}
public void setXmlSendLead(String xmlSendLead) {
this.xmlSendLead = xmlSendLead;
}
public int getStatutEnvoieSendLead() {
return statutEnvoieSendLead;
}
public void setStatutEnvoieSendLead(int statutEnvoieSendLead) {
this.statutEnvoieSendLead = statutEnvoieSendLead;
}
public Date getDateEnvoieSendLead() {
return dateEnvoieSendLead;
}
public void setDateEnvoieSendLead(Date dateEnvoieSendLead) {
this.dateEnvoieSendLead = dateEnvoieSendLead;
}
public int getContactWebId() {
return contactWebId;
}
public void setContactWebId(int contactWebId) {
this.contactWebId = contactWebId;
}
public String getXmlSimulation() {
return xmlSimulation;
}
public void setXmlSimulation(String xmlSimulation) {
this.xmlSimulation = xmlSimulation;
}
public int getStatutEnvoieSimulation() {
return statutEnvoieSimulation;
}
public void setStatutEnvoieSimulation(int statutEnvoieSimulation) {
this.statutEnvoieSimulation = statutEnvoieSimulation;
}
}
我的自动递增主键ID看起来正常,我的日期也是如此,因为我的旧数据已成功检索。但是当我进行打印时,Date的格式如下:
Mon Feb 06 16:03:57 GMT + 01:00 2017
我如何打印:
DatabaseHelper db = new DatabaseHelper(getActivity());
Dao<Demandes, Integer> demandesDao = null;
try {
demandesDao = db.getDemandesDao();
final List<Demandes> demandes = demandesDao.queryForAll();
System.out.println(demandes);
} catch (SQLException e) {
e.printStackTrace();
}
这是ORMLite中的一种独特格式吗?