/**
* requires import oracle.jbo.domain.Date;
*/
protected Date getCurrentDate()
{
return new Date( Date.getCurrentDate());
}
/**
* requires import oracle.jbo.Domain.Date and java.sql.Timestamp
*/
protected Date getCurrentDateWithTime()
{
return new Date( new Timestamp( System.currentTimeMillis()));
}
Conventing from a date of type java.util.Date to an oracle.jbo.domain.Date can be achieved using the following technique (the code also demonstrates the use of a date parser to convert arbitrary date formats to valid Java dates.) :
protected static final DateFormat dateFormater = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
public void setDateFromString( String value)
{
try {
java.util.Date javaDate = dateFormater.parse(value);
Timestamp curTimestamp = new Timestamp( javaDate.getTime());
oracle.jbo.domain.Date oracleDate = new oracle.jbo.domain.Date(curTimestamp);
this.setAccidentDate( oracleDate);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Unable to parse date value " + value);
}
}
0 comments:
Post a Comment