日期:2014-05-20 浏览次数:20572 次
public class StringFormatDemo { public static String format(int number){ Date date=new Date(); DateFormat df=new SimpleDateFormat("yyyyMMdd"); String s1=df.format(date); NumberFormat nf=new DecimalFormat("0000"); String s2=nf.format(number); return s1+s2; } public static void main(String[] args) { System.out.println(format(1)); } }
------解决方案--------------------
have a try
int id = 12; String s = String.format("%tF%04d", new Date(), id).replaceAll("-", ""); System.out.println(s);
------解决方案--------------------
orcale
select to_char(sysdate, 'YYYYMMDD') | to_char(id, '0000') from dual
------解决方案--------------------
select replace(to_char(sysdate, 'YYYYMMDD') || to_char(1, '0000'),' ','') from dual