java.lang.Object
java.util.Date
java.sql.Date
- All Implemented Interfaces:
- Serializable, Cloneable, Comparable<Date>
- See Also:
- Top Examples, Source Code
@Deprecated
public Date(int year,
int month,
int day)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public Date(long date)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[299]Convert util.Date to sql.Date
By Anonymous on 2005/03/19 16:02:17 Rate
public static java.sql.Date getSqlDate ( java.util.Date date ) {
if ( date == null ) {
return null;
} else {
return new java.sql.Date ( date.getTime ( ) ) ;
}
}
[309]_
By Anonymous on 2003/07/13 12:48:38 Rate
sqlDate = new java.sql.Date ( System.currentTimeMillis ( ) ) ) ;
[1534]_
By Anonymous on 2005/09/13 06:48:23 Rate
java.sql.Date stores only date information, not times. Simply converting a java.util.Date into a java.sql.Date will silently set the time to midnight. So, to store date/times to be manipulated as java.util.Date objects,
//don??t do this:
// BUG: loses time of day
preparedStatement.setDate ( 1, new java.sql.Date ( date.getTime ( ) ) ) ;
//do this instead:
preparedStatement.setTimestamp ( 1, new java.sql.Timestamp ( date.getTime ( ) ) ) ;
@Deprecated
public int getHours()
- See Also:
setHours(int)
, IllegalArgumentException, Date
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
@Deprecated
public int getMinutes()
- See Also:
setMinutes(int)
, IllegalArgumentException, Date
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
@Deprecated
public int getSeconds()
- See Also:
setSeconds(int)
, IllegalArgumentException, Date
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
@Deprecated
public void setHours(int i)
- See Also:
getHours()
, IllegalArgumentException, Date
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
@Deprecated
public void setMinutes(int i)
- See Also:
getMinutes()
, IllegalArgumentException, Date
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
@Deprecated
public void setSeconds(int i)
- See Also:
getSeconds()
, IllegalArgumentException, Date
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public void setTime(long date)
- See Also:
- Date
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1287]Formating sql.Timestamp
By anand_k_durgam { at } yahoo { dot } com on 2005/03/12 11:32:22 Rate
import java.util.*;
import java.text.*;
public class TestTimeStampOne2 {
public static void main ( String [ ] args ) {
String time = "01/27/2005 03:04:43 PM EST";
java.util.Date date1 = new java.util.Date ( ) ;
long time1 = date1.parse ( time ) ;
java.sql.Timestamp timeStamp = new java.sql.Timestamp ( time1 ) ;
String format="MM/dd/yyyy HH:mm:ss z";
java.text.SimpleDateFormat f = new java.text.SimpleDateFormat ( format ) ;
String registrationTime = f.format ( timeStamp ) ;
System.out.println ( "Hello World! "+registrationTime ) ;
}
}
public String toString()
- See Also:
Date.toGMTString()
, Date.toLocaleString()
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
public static Date valueOf(String s)
- See Also:
- IllegalArgumentException
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples