ITeye博客

String类 Example

speed847 · 2009-05-15 11:25 · Java · Markdown

1.

String[] aa =

"aaa bbb ccc s q s x".split("\\t");

for (int i = 0 ; i<aa.length;i++) {

System.

out.println("--"+aa[i]);

}

 

2. String --> Double(Integer)

 

 

 

 

new Double(Double.parseDouble("1.11"));

 

3.

double d1 = 234.3434343;
DecimalFormat df=new DecimalFormat("#.00");
System.out.println(df.format(d1));

 

4.

 

 

 

 

java.text.SimpleDateFormat sdf =

 

new java.text.SimpleDateFormat("M-yyyy",java.util.Locale.US

);

java.util.Date d = sdf.parse(

 

"12-2003"

);

 

 

long

dvalue=d.getTime();

SimpleDateFormat formatter =

 

new SimpleDateFormat("yyyy-MM"

);

String mDateTime1=formatter.format(d);

System.

 

out

.println(mDateTime1);

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。