DateFormat类获得当前时间
2016-07-29 14:45
190 查看
结果为:
使用DateFormat类获取系统的当前时间的示例如下所示:
SHORT 模式的日期为:12-2-17 下午7:43
MEDIUM 模式的日期为:2012-2-17 19:43:39
LONG 模式的日期为:2012年2月17日 下午07时43分39秒
FULL 模式的日期为:2012年2月17日 星期五 下午07时43分39秒 CST
[html] view plain copy
import java.text.DateFormat;
import java.util.Date;
public class DateFormatClass {
}
使用DateFormat类获取系统的当前时间的示例如下所示:
SHORT 模式的日期为:12-2-17 下午7:43
MEDIUM 模式的日期为:2012-2-17 19:43:39
LONG 模式的日期为:2012年2月17日 下午07时43分39秒
FULL 模式的日期为:2012年2月17日 星期五 下午07时43分39秒 CST
[html] view plain copy
import java.text.DateFormat;
import java.util.Date;
public class DateFormatClass {
public static void main(String[] args) { DateFormatClass.date_Format(); } public static void date_Format() { System.out.println("使用DateFormat类获取系统的当前时间的示例如下所示:"); Date date = new Date(); DateFormat shortDateFormat = DateFormat.getDateTimeInstance( DateFormat.SHORT, DateFormat.SHORT); DateFormat mediumDateFormat = DateFormat.getDateTimeInstance( DateFormat.MEDIUM, DateFormat.MEDIUM); DateFormat longDateFormat = DateFormat.getDateTimeInstance( DateFormat.LONG, DateFormat.LONG); DateFormat fullDateFormat = DateFormat.getDateTimeInstance( DateFormat.FULL, DateFormat.FULL); System.out.println("SHORT 模式的日期为:" + shortDateFormat.format(date)); System.out.println("MEDIUM 模式的日期为:" + mediumDateFormat.format(date)); System.out.println("LONG 模式的日期为:" + longDateFormat.format(date)); System.out.println("FULL 模式的日期为:" + fullDateFormat.format(date)); }
}
相关文章推荐
- DateFormat类获得当前时间
- PHP的date()获得当前时间 少8个小时的解决
- 让页面加载的时候自动获得当前时间加载到DateBox中
- 获取android中的 SimpleDateFormat——获取当前时间
- Java常用类:Data()的用法,获得当前日期和时间对象date 定义对象Date date1 = new Date(36000000);获得包含的日期和时间 比较date和date1是否相等
- java获取当前时间后,经SimpleDateFormat格式化成String类型,差8小时
- php5中date()获得的时间不是当前时间的解决方法
- 使用DateFormat类获取系统的当前时间
- 在java程序中获得当前时间的前一天时间及Calendar与Date的转换
- PHP的date()获得当前时间 少8个小时的解决方法
- 获取当前时间,并以要求格式展示SimpleDateFormat
- Java中通过SimpleDateFormat格式化当前时间:/** 输出格式:20060101010101001**/
- java获得当前时间的前一天时间及Calendar 与 Date 的转换
- java获得当前时间的前一天时间及Calendar 与 Date 的转换
- JAVA开发9--获取当前时间--SimpleDateFormat
- Date获得当前时间,后获得年月日的方法,已经不在被经常使用,需要更新了
- Angularjs date过滤器获得当前时间
- js 的date的format时间,获取当前时间,前一天的日期
- php的date()函数获得的小时数目比当前时间少8小时的解决方法
- php5 date()获得的时间不是当前时间