Timestamp에 맞먹는 것을 사용해야...


[ 다음 글들 ] [ 이어서 글올리기(답하기) ] [ 자바 묻고 답하기 ]

글쓴이 :박찬우 2000년 5월 01일 20:56:38

In Reply to: DATE형 필드에 관해 posted by 박진성 on 2000년 5월 01일 15:51:36:

package java.sql;


/**
* <P>This class is a thin wrapper around java.util.Date that allows
* JDBC to identify this as a SQL TIMESTAMP value. It adds the ability
* to hold the SQL TIMESTAMP nanos value and provides formatting and
* parsing operations to support the JDBC escape syntax for timestamp
* values.
*
* <P><B>Note:</B> This type is a composite of a java.util.Date and a
* separate nanos value. Only integral seconds are stored in the
* <code>java.util.Date</code> component. The fractional seconds - the nanos - are
* separate. The <code>getTime</code> method will return only integral seconds. If
* a time value that includes the fractional seconds is desired, you
* must convert nanos to milliseconds (nanos/1000000) and add this to
* the <code>getTime</code> value. The
* <code>Timestamp.equals(Object)</code> method never returns
* true when passed a value of type <code>java.util.Date</code>
* because the nanos component of a date is unknown.
* As a result, the <code>Timestamp.equals(Object)</code>
* method is not symmetric with respect to the
* <code>java.util.Date.equals(Object)</code>
* method. Also, the <code>hashcode</code> method uses the underlying
* <code>java.util.Data</code>
* implementation and therefore does not include nanos in its computation.
*
* Due to the differences between the <code>Timestamp</code> class
* and the <code>java.util.Date</code>
* class mentioned above, it is recommended that code not view
* <code>Timestamp</code> values generically as an instance of
* <code>java.util.Date</code>. The
* inheritance relationship between <code>Timestamp</code>
* and <code>java.util.Date</code> really
* denotes implementation inheritance, and not type inheritance.
*/
public class Timestamp extends java.util.Date {


/**
* Constructs a <code>Timestamp</code> object initialized
* with the given values.
*
* @param year year-1900
* @param month 0 to 11
* @param day 1 to 31
* @param hour 0 to 23
* @param minute 0 to 59
* @param second 0 to 59
* @param nano 0 to 999,999,999
* @deprecated instead use the constructor <code>Timestamp(long millis)</code>
*/
public Timestamp(int year, int month, int date,
int hour, int minute, int second, int nano) {
super(year, month, date, hour, minute, second);
if (nano > 999999999 || nano < 0) {
throw new IllegalArgumentException("nanos > 999999999 or < 0");
}
nanos = nano;
}


/**
* Constructs a <code>Timestamp</code> object
* using a milliseconds time value. The
* integral seconds are stored in the underlying date value; the
* fractional seconds are stored in the <code>nanos</code> field of
* the <code>Timestamp</code> object.
*
* @param time milliseconds since January 1, 1970, 00:00:00 GMT.
* A negative number is the number of milliseconds before
* January 1, 1970, 00:00:00 GMT.
*/
public Timestamp(long time) {
super((time/1000)*1000);
nanos = (int)((time%1000) * 1000000);
if (nanos < 0) {
nanos = 1000000000 + nanos;
setTime(((time/1000)-1)*1000);
}
}


...
이하 생략



다음 글들:



이어서 글올리기(답하기)

이름:
E-Mail:
제목:
내용:
HTML 태그 포함 여부: HTML 문서일 경우 체크
관련 URL(선택):
URL 제목(선택):
관련 이미지 URL:


[ 다음 글들 ] [ 이어서 글올리기(답하기) ] [ 자바 묻고 답하기 ]