Foreground to background Java when data date type conversion, Java to database data date format conversion __ Other

Source: Internet
Author: User

Foreground to background Java when data date type conversion, Java to database data date format conversion

Foreground to Java:

Entity class with @datetimeformat so that is the passing of the empty string can also be transferred to the same format as the previous pass

@XmlElement (name = "Begindate")

@DateTimeFormat (pattern = "YYYYMMDD")

Private Date begindate;

End Date

@XmlElement (name = "EndDate")

@DateTimeFormat (pattern = "YYYYMMDD")

Private Date EndDate;

You don't need a format that's passed in front of you.

SimpleDateFormat sfdate = new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss");

String Str=sfdate.format (Entity.gettrandate ());//entity.gettrandate ();

Java to database:

Java to database with To_date (' 2017-04-07 00:00:00 ', ' yyyy-mm-dd HH24:MI:SS ');

String str= "2017-04-07 00:00:00";

list<tbsettinmoney> tb= jdbctemplate.query ("select * from Tb_sett_inmoney t where T.acct_date=to_date (?, ' YYYY-MM -dd HH24:MI:SS ') ", New Object[]{str},new RowMapper () {

@Override

Public Object Maprow (ResultSet rs, int rownum) throws SQLException {

TODO auto-generated Method Stub

Tbsettinmoney tb= new Tbsettinmoney ();

Tb.setsupacctid (rs.getstring ("sup_acct_id"));

Tb.setcustflag (Rs.getint ("Cust_flag"));

Tb.settrandate (Rs.getdate ("tran_date"));

return TB;

}

});

Jdbctemplate.queryforlist ("select * from Tb_sett_fund t where t.sup_acct_id=?", New Object[]{str}, New Tbsettfund ());

System.out.println (Tb.size ());

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.