1.Date对象:Date date = getDate(); 2.Calendar实例:Calendar calendar = Calendar.getInstance(); 3.calendar.setTime(date); 4.int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH); int day = calendar.get(Calendar.DAY_OF_MONTH); 参考网址
抄的人家的,仅作学习使用. java Date获取 年月日时分秒 package com.util; import java.text.DateFormat; import java.util.Calendar; import java.util.Date; public class Test { public void getTimeByDate(){ Date date = new Date(); DateFormat df1 =
date 表示年月日,如YY-MM-DD datetime 表示年月日和时间信息,如YY-MM-DD HH:MM:SS datestamp 和datetime表示的信息相同,但时间范围不同 时间范围 date -- > '1000-01-01' to '9999-12-31'. datetime --> '1000-01-01 00:00:00' to '9999-12-31 23:59:59'. datestamp -- > '1970-01-01 00:00:01' UTC to '
JavaScript_Date对象说明 Date中文为"日期"的意思,Date继承自Object对象,此对象提供操作,显示日期与时间的函数 Date对象构造函数 Date对象具有多种构造函数. new Date() new Date(milliseconds) new Date(datestring) new Date(year, month) new Date(year, month, day) new Date(year, month, day, hours) new Date(
java.util.Date: 构造方法 public Date() 空参构造,返回当前时间 public Date(long 毫秒值) 指定毫秒值的时间 普通方法 long getTime() 获取毫秒值 viod setTime() 设置毫秒值 Date 指定毫秒数和Date类型的转换 Date d = new Date(); 重写toString方法:Sat Mar 25 15:33:29 CST 2017 java.text.DateFormat 日期格式化类 抽象类 将日期和指定格式字