Get Current JBO Date with Time
oracle.jbo.domain.Date
, we can use this code, this code can be written in model implementation classes or in Managed Bean
/**Method to get current JBO Date with time part
* @return
*/
public Date getCurrentJboDate(){
Date currentDate = (Date) Date.getCurrentDate();
return currentDate;
}
Get the current JBO Date in a Specific format (JBO Date without time part)
There are times when you need to work with just the date and not the time, whether it's for formatting purposes or for cleaner data extraction. In such cases, you can use a simple code snippet to retrieve the date in a specific format. Here's how you can do it!
/**Method to get current JBO Date in Specific format
* @return
*/
public Date getformattedJboDate() {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MMM-dd");
java.util.Date date = new java.util.Date();
String date1 = dateFormat.format(date);
try {
date = dateFormat.parse(date1);
} catch (ParseException e) {
e.printStackTrace();
}
java.sql.Date sqlDate = new java.sql.Date(date.getTime());
oracle.jbo.domain.Date formattedDate = new oracle.jbo.domain.Date(sqlDate);
return formattedDate;
}
Convert java.util Date to java.sql Date
/**Method to convert java.util.Date to java.sql.Date
* @return
*/
public java.sql.Date convertToSqlDate() {
//Util Date
java.util.Date date = new java.util.Date();
//SQL Date
java.sql.Date sqlDate = new java.sql.Date(date.getTime());
return sqlDate;
}
Convert java.util Date to oracle.jbo.domain Date
/**Method to convert java.util.Date to oracle.jbo.domain.Date
* @return
*/
public Date convertToJboDate() {
//Util Date
java.util.Date date = new java.util.Date();
//SQL Date
java.sql.Date sqlDate = new java.sql.Date(date.getTime());
//JBO Date
oracle.jbo.domain.Date jboDate = new oracle.jbo.domain.Date(sqlDate);
return jboDate;
}