美文网首页
java基本类型(Date 日期等)

java基本类型(Date 日期等)

作者: guotong314 | 来源:发表于2017-06-12 16:24 被阅读0次

1  基本类型转换为字符串

int c = 10

String str = Integer.toString(c);  方法1

String str1 = String.valueof(c); 方法2

STring Str2 = c+ "";方法3

2  字符串转换成基本类型

String str = "8";

int d = Integer.parseInt(str);方法1

int e = Integer.valueof(str);方法2

3   时间规范化

Date d = new Date();

SimpleDateFormat sd = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");

String dateStr = sd.format(d);  //使用 format() 方法将日期转换为指定格式的文本

Date date = df.parse(dateStr); // 使用 parse() 方法将文本转换为日期

4  日期

5  算术类 Math

相关文章

网友评论

      本文标题:java基本类型(Date 日期等)

      本文链接:https://www.haomeiwen.com/subject/blilqxtx.html