就是在Date和String,number和string间的转换的模式。
解决方案 »
- 请教例子问题
- java与数据库联系问题,请高手帮忙!
- 繁体插入数据库 乱码
- JAVA中怎样自动生成不重复的数字(急)
- 问下这个是啥用法
- jbuilder多次運行后,爲什麽會出現tomcat 4.0 http 8080,tomcat 4.0 http 8083...?
- java线程的问题
- 菜鸟问Visual J++ 6.0的问题
- jdbc 连接sql server2000 错误<未与信任 SQL Server 连接相关联>
- applet中的JComboBox不能下拉的问题。。。
- 弱弱的问一下general purpose programming language 是什么意思啊?
- 救命,一个关于Echopoint的问题
import java.util.*;public class Test
{
public static void main(String[] args)
{
SimpleDateFormat formatter = new SimpleDateFormat ("EEE MMM dd hh:mm:ss yyyy", Locale.getDefault());
System.out.println(formatter.format(new Date()));
//格式化当前JVM的时间,已“EEE MMM dd hh:mm:ss yyyy”格式和JVM默认当地日期格式符号输出
int s,m;
formatter = new SimpleDateFormat("s",Locale.getDefault());
try
{
s = Integer.parseInt(formatter.format(new Date()));
System.out.println(s);
}
catch (NumberFormatException n)
{
s = 0;
}
formatter.applyPattern("m");
try
{
m = Integer.parseInt(formatter.format(new Date()));
System.out.println(s);
}
catch (NumberFormatException n)
{
m = 0;
}
}
}
运行结果:星期二 八月 05 02:36:18 2003
18
18