---
title: "String类 Example"
author: "speed847"
date: "2009-05-15T11:25:10Z"
tags: []
slug: "string-example"
draft: false
lastmod: "2009-05-15T16:55:03Z"
id: 387316
url: "https://speed847.iteye.com/blog/387316"
---

1\.

String\[] aa =

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

**for** (**int** i = 0 ; i&lt;aa.length;i++) {

System.

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

}

 

2\. String --&gt; 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);