Java-API:java.util.Date
Posted storebook
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java-API:java.util.Date相关的知识,希望对你有一定的参考价值。
ylbtech-Java-API:java.util.Date |
- java.lang.Object
-
- java.util.Date
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<Date>
1.返回顶部 |
1、
-
Constructor Summary
Constructors Constructor Description Date()
Allocates aDate
object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.Date?(int year, int month, int date)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(year + 1900, month, date)
orGregorianCalendar(year + 1900, month, date)
.Date?(int year, int month, int date, int hrs, int min)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(year + 1900, month, date, hrs, min)
orGregorianCalendar(year + 1900, month, date, hrs, min)
.Date?(int year, int month, int date, int hrs, int min, int sec)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(year + 1900, month, date, hrs, min, sec)
orGregorianCalendar(year + 1900, month, date, hrs, min, sec)
.Date?(long date)
Allocates aDate
object and initializes it to represent the specified number of milliseconds since the standard base time known as "the epoch", namely January 1, 1970, 00:00:00 GMT.Date?(String s)
Deprecated.As of JDK version 1.1, replaced byDateFormat.parse(String s)
.
-
Method Summary
All MethodsStatic MethodsInstance MethodsConcrete MethodsDeprecated Methods Modifier and Type Method Description boolean
after?(Date when)
Tests if this date is after the specified date.boolean
before?(Date when)
Tests if this date is before the specified date.Object
clone()
Return a copy of this object.int
compareTo?(Date anotherDate)
Compares two Dates for ordering.boolean
equals?(Object obj)
Compares two dates for equality.static Date
from?(Instant instant)
Obtains an instance ofDate
from anInstant
object.int
getDate()
Deprecated.As of JDK version 1.1, replaced byCalendar.get(Calendar.DAY_OF_MONTH)
.int
getDay()
Deprecated.As of JDK version 1.1, replaced byCalendar.get(Calendar.DAY_OF_WEEK)
.int
getHours()
Deprecated.As of JDK version 1.1, replaced byCalendar.get(Calendar.HOUR_OF_DAY)
.int
getMinutes()
Deprecated.As of JDK version 1.1, replaced byCalendar.get(Calendar.MINUTE)
.int
getMonth()
Deprecated.As of JDK version 1.1, replaced byCalendar.get(Calendar.MONTH)
.int
getSeconds()
Deprecated.As of JDK version 1.1, replaced byCalendar.get(Calendar.SECOND)
.long
getTime()
Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by thisDate
object.int
getTimezoneOffset()
Deprecated.As of JDK version 1.1, replaced by-(Calendar.get(Calendar.ZONE_OFFSET) + Calendar.get(Calendar.DST_OFFSET)) / (60 * 1000)
.int
getYear()
Deprecated.As of JDK version 1.1, replaced byCalendar.get(Calendar.YEAR) - 1900
.int
hashCode()
Returns a hash code value for this object.static long
parse?(String s)
Deprecated.As of JDK version 1.1, replaced byDateFormat.parse(String s)
.void
setDate?(int date)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(Calendar.DAY_OF_MONTH, int date)
.void
setHours?(int hours)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(Calendar.HOUR_OF_DAY, int hours)
.void
setMinutes?(int minutes)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(Calendar.MINUTE, int minutes)
.void
setMonth?(int month)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(Calendar.MONTH, int month)
.void
setSeconds?(int seconds)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(Calendar.SECOND, int seconds)
.void
setTime?(long time)
Sets thisDate
object to represent a point in time that istime
milliseconds after January 1, 1970 00:00:00 GMT.void
setYear?(int year)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(Calendar.YEAR, year + 1900)
.String
toGMTString()
Deprecated.As of JDK version 1.1, replaced byDateFormat.format(Date date)
, using a GMTTimeZone
.Instant
toInstant()
Converts thisDate
object to anInstant
.String
toLocaleString()
Deprecated.As of JDK version 1.1, replaced byDateFormat.format(Date date)
.String
toString()
Converts thisDate
object to aString
of the form:static long
UTC?(int year, int month, int date, int hrs, int min, int sec)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(year + 1900, month, date, hrs, min, sec)
orGregorianCalendar(year + 1900, month, date, hrs, min, sec)
, using a UTCTimeZone
, followed byCalendar.getTime().getTime()
.
2、
2.返回顶部 |
3.返回顶部 |
4.返回顶部 |
5.返回顶部 |
0、
1、
6.返回顶部 |
![]() |
作者:ylbtech 出处:http://ylbtech.cnblogs.com/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。 |
以上是关于Java-API:java.util.Date的主要内容,如果未能解决你的问题,请参考以下文章
java.util.Date 和 XMLGregorianCalendar 之间的简单转换
如何从 java.sql.Timestamp 转换为 java.util.Date?
如何在 GMT(格林威治)时间将 XMLGregorianCalendar 转换为 java.util.Date