Converting java.lang.String to oracle.jbo.domain.Date

Requirement- to convert date as a string to oracle.jbo.domain.Date.

Solutions-

/**
*Converts a String to oracle.jbo.domain.Date
* @param String
* @return oracle.jbo.domain.Date
*/
public oracle.jbo.domain.Date castToJBODate(String aDate){
          DateFormat formatter;
          java.util.Date date; 

          if(aDate!=null){

            try {

              formatter = new SimpleDateFormat("dd/MMM/yyyy");
              date = formatter.parse(aDate);
              java.sql.Date sqlDate = new java.sql.Date(date.getTime());
              oracle.jbo.domain.Date jboDate = new oracle.jbo.domain.Date(sqlDate);

                return jboDate;
               } catch (ParseException e) {

                        e.printStackTrace();
                }

         }

         return null;
}

Another scenario –Convert oracle.jbo.domain.Date to String

Use this code-

 public String convertJbodateToString(oracle.jbo.domain.Date domainDate){
        
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");  
        Date date = null;
        
        try {
            date = formatter.parse(domainDate.toString().substring(0, 21));
        } catch (ParseException e) {
        }
        
                
        SimpleDateFormat FORMATTER = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
        System.out.println("NewDate-->" + FORMATTER.format(date));
        
        return FORMATTER.format(date);
    }

Happing coding with Vinay in techartifact

Get current date, time , timestamp in Java

You can get the current date time via following two classes – Date and Calendar. And, later use SimpleDateFormat class to convert the date into user friendly format.

-> Date() + SimpleDateFormat()

DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yy HH:mm:ss");
Date date = new Date();
System.out.println(dateFormat.format(date));

-> get the time

Date date = new Date();
System.out.println(date.getTime());

-> get the time stamp

Date date = new Date();
System.out.println(new Timestamp(date.getTime()));

You can define various format i.e

-> dd-MMM-yy HH:mm:ss
-> yyyy/MM/dd HH:mm:ss
-> yy/MM/dd HH:mm:ss

You can use as working code like

import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
 
 
public class GetCurrentDateTime {
  public static void main(String[] args) {
 
	   DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
	   //get current date time with Date()
	   Date date = new Date();
	   System.out.println(dateFormat.format(date));
            
           //get the time
           Date date = new Date();
	   System.out.println(new Timestamp(date.getTime()));

           // get the timestamp
 
  }
}

Error while deploying ADF application into WebLogic Server 11g

Normally we get the error,While deploying ADF application into WebLogic Server 11g,
*****************************************************************************************************
An error occurred during activation of changes, please see the log for details.[J2EE:160149]Error while processing library references. Unresolved application library references, defined in weblogic-application.xml: [Extension-Name: adf.oracle.domain, exact-match: false].
*****************************************************************************************************

Solution:

1. Login to WebLogic Server 11g Console

2. Click on Deployements

3. Click on adf.oracle.domain(1.0,11.1.1.2.0) library

4. Click on Targets tab and select the server where the application going to be deployed (Select only server which is used for ADF deployment, if you have UCM server than uncheck it)

5. Click on “Save”

Follow same steps from 3 to 5 on following library too


– adf.oracle.businesseditor(1.0,11.1.1.2.0)
– adf.oracle.domain.webapp(1.0,11.1.1.2.0)
– jstl(1.2,1.2.0.1)
– jsf(1.2,1.2.9.0)

Try again deploying,it will work now.

Happy coding with Vinay in techartifact…..