Date获得当前时间,后获得年月日的方法,已经不在被经常使用,需要更新了
2017-01-12 11:16
393 查看
import java.util.Calendar;
public class SysDate {
public static void main(String[] args) {
Calendar c = Calendar.getInstance();
System.out.println("年:" + c.get(Calendar.YEAR));
System.out.println("月:" + (c.get(Calendar.MONTH) + 1));
System.out.println("日:" + c.get(Calendar.DAY_OF_MONTH));
System.out.println("24时制小时:" + c.get(Calendar.HOUR_OF_DAY));
System.out.println("12时制:" + c.get(Calendar.HOUR));
System.out.println("分:" + c.get(Calendar.MINUTE));
System.out.println("秒:" + c.get(Calendar.SECOND));
System.out.println("今天是一年中的第:" + c.get(Calendar.DAY_OF_YEAR) + "天");
}
}
还有很多,自己发现吧。
public class SysDate {
public static void main(String[] args) {
Calendar c = Calendar.getInstance();
System.out.println("年:" + c.get(Calendar.YEAR));
System.out.println("月:" + (c.get(Calendar.MONTH) + 1));
System.out.println("日:" + c.get(Calendar.DAY_OF_MONTH));
System.out.println("24时制小时:" + c.get(Calendar.HOUR_OF_DAY));
System.out.println("12时制:" + c.get(Calendar.HOUR));
System.out.println("分:" + c.get(Calendar.MINUTE));
System.out.println("秒:" + c.get(Calendar.SECOND));
System.out.println("今天是一年中的第:" + c.get(Calendar.DAY_OF_YEAR) + "天");
}
}
还有很多,自己发现吧。
相关文章推荐
- php的date()函数获得的小时数目比当前时间少8小时的解决方法
- 使用date对象显示系统当前时间并自动更新
- php5中date()获得的时间不是当前时间的解决方法
- Android动态显示系统时间,附获得当前年月日星期时分秒方法,一步到位
- 通常我们使用[NSDate date]方法得到的时间与当前时间不一致,如何解决?
- PHP的date()获得当前时间 少8个小时的解决方法
- mysql中使date字段使用默认值(即当前时间)自动添加
- DateFormat类获得当前时间
- BOOST:使用local_date_time 计算当前时间戳
- Java中获得当前时间的方法
- jsp中从页面获得String类型时间字符串,存入Oracle中Date类型字段方法
- ios 开发中获得当前时间的 年月日,时分秒
- PHP开发中Date()时间日期函数的使用方法
- PHP中Date获取时间不正确的解决方法(2009-05-15更新)
- PHP的date()获得当前时间 少8个小时的解决
- java使用new Date()和System.currentTimeMillis()获取当前时间戳
- 输入日期,计算出与当前系统日期相隔多少天(获取系统时间,年月日分别获取,对其进行格式化simpledateformat;输入的日期类似操作)
- PHP的date()获得当前时间 少8个小时的解决
- JAVA获得当前时间的几种方法
- JAVA获得当前时间的几种方法