---恢复内容开始---
http://tool.oschina.net/apidocs/apidoc?api=jdk-zh
https://www.jianshu.com/p/c8f16cab35e1#
参考官方的 api说明文档,format是一个抽象接口,已知的实现类有DateFormat,MessageFormat,NumberFormat
关于时间的DateFormat,我们一般是直接使用它的子类:SimpleDateFormat,具体的y,m,d,之类的用法可以参考百度
例子如下:获取当前系统的时间并格式化
package test; import java.text.SimpleDateFormat; import java.util.Date; import org.json.JSONArray; import org.json.JSONObject; public class test2 { public static void main(String[] args) { //获取系统当前时间 long currentTime = System.currentTimeMillis(); Date date = new Date(currentTime); System.out.println(date); //进行格式化,获取自己想要的格式 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日HH时mm分"); System.out.println(dateFormat.format(date)); } }
关于NumberFormat,它的直接实现子类有ChoiceFormat和DecimalFormat,我们一般使用DecimalFormat
---恢复内容结束---
---恢复内容开始---
http://tool.oschina.net/apidocs/apidoc?api=jdk-zh
https://www.jianshu.com/p/c8f16cab35e1#
参考官方的 api说明文档,format是一个抽象接口,已知的实现类有DateFormat,MessageFormat,NumberFormat
关于时间的DateFormat,我们一般是直接使用它的子类:SimpleDateFormat,具体的y,m,d,之类的用法可以参考百度
例子如下:获取当前系统的时间并格式化
package test; import java.text.SimpleDateFormat; import java.util.Date; import org.json.JSONArray; import org.json.JSONObject; public class test2 { public static void main(String[] args) { //获取系统当前时间 long currentTime = System.currentTimeMillis(); Date date = new Date(currentTime); System.out.println(date); //进行格式化,获取自己想要的格式 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日HH时mm分"); System.out.println(dateFormat.format(date)); } }
关于NumberFormat,它的直接实现子类有ChoiceFormat和DecimalFormat,我们一般使用DecimalFormat
---恢复内容结束---
---恢复内容开始---
http://tool.oschina.net/apidocs/apidoc?api=jdk-zh
https://www.jianshu.com/p/c8f16cab35e1#
参考官方的 api说明文档,format是一个抽象接口,已知的实现类有DateFormat,MessageFormat,NumberFormat
关于时间的DateFormat,我们一般是直接使用它的子类:SimpleDateFormat,具体的y,m,d,之类的用法可以参考百度
例子如下:获取当前系统的时间并格式化
package test; import java.text.SimpleDateFormat; import java.util.Date; import org.json.JSONArray; import org.json.JSONObject; public class test2 { public static void main(String[] args) { //获取系统当前时间 long currentTime = System.currentTimeMillis(); Date date = new Date(currentTime); System.out.println(date); //进行格式化,获取自己想要的格式 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日HH时mm分"); System.out.println(dateFormat.format(date)); } }
关于NumberFormat,它的直接实现子类有ChoiceFormat和DecimalFormat,我们一般使用DecimalFormat
---恢复内容结束---
---恢复内容开始---
http://tool.oschina.net/apidocs/apidoc?api=jdk-zh
https://www.jianshu.com/p/c8f16cab35e1#
参考官方的 api说明文档,format是一个抽象接口,已知的实现类有DateFormat,MessageFormat,NumberFormat
关于时间的DateFormat,我们一般是直接使用它的子类:SimpleDateFormat,具体的y,m,d,之类的用法可以参考百度
例子如下:获取当前系统的时间并格式化
package test; import java.text.SimpleDateFormat; import java.util.Date; import org.json.JSONArray; import org.json.JSONObject; public class test2 { public static void main(String[] args) { //获取系统当前时间 long currentTime = System.currentTimeMillis(); Date date = new Date(currentTime); System.out.println(date); //进行格式化,获取自己想要的格式 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日HH时mm分"); System.out.println(dateFormat.format(date)); } }
关于NumberFormat,它的直接实现子类有ChoiceFormat和DecimalFormat,我们一般使用DecimalFormat
---恢复内容结束---
原文:https://www.cnblogs.com/zengcongcong/p/10580758.html