用java实现把当前时间转换成无符号的字符串
import java.util.Date;
import java.text.SimpleDateFormat;
public class CurrentTime
{
public String getCurrentTime()//获得当前时间
{
Date now = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
String time= dateFormat.format( now );
return time;
}
public String splitString(String str,String n)//字符拆分方法
{
String st[]=str.split(n);
str="";
for(int i=0;i{
str=str+st[i];
}
return str;
}
public String doChangedTime() //对字符进行拆分
{
String time,now;
time=getCurrentTime();
now=splitString(time,"\\:");
time=splitString(now,"/");
now=splitString(time," ");
return now;
}
public static void main(String ar[])
{
System.out.println(new CurrentTime().getCurrentTime());//字符拆分之前
System.out.println(new CurrentTime().doChangedTime());//字符拆分之后}
}