Java string formatting, java string
1. Use the String. format method.
Java. util. Date d = new java. util. Date ();
SimpleDateFormat df = new SimpleDateFormat ("yyyy-MM-dd HH: mm: ss ");
String s = df. format (d );
String SQL = String. format ("insert into FirstLevelTitle values (% d, '% s')", 13, "technology", "Administrator ", s );
% S indicates the string type, and % d indicates the integer type (decimal)
For other types of representation, see:
Http://blog.csdn.net/lonely_fireworks/article/details/7962171
Http://www.cnblogs.com/fsjohnhuang/p/4094777.html
2. Use the MessageFormat. format Method
String SQL = MessageFormat. format ("insert into FirstLevelTitle values ({0},'' {1} '','' {2} '','' {3} '')", 14, "technology", "Administrator", s );
Note: single quotes must be expressed in two single quotes.
For more information, see:
Http://blog.csdn.net/zhiweianran/article/details/8666992