Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Issue converting from oracle.jbo.domain.Date to java.util.Calendar and oracle.jbo.domain.Timestamp b

JDeveloper Newbie (11.1.1.6.0)Dec 26 2013 — edited Dec 27 2013

Hi everyone,

Working with dates has been more difficult than I thought! Please take a look at the code; everything compiles, but it fails because I am not casting correctly. Any help would be appreciated.

Here are the imports:

import java.sql.SQLException;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Calendar;

import oracle.jbo.domain.Date;

import oracle.jbo.domain.Timestamp;

Here is the method:

    public static Date nextDay(String sDate, int day,

                              String simpleDateFormat) {

        Date result = null;

        java.util.Date date;

        if (sDate != null) {

            try {

                System.out.println("try...");

                Calendar calendar = Calendar.getInstance();

                SimpleDateFormat dateFormat =

                    new SimpleDateFormat(simpleDateFormat);

                calendar.setTime(dateFormat.parse(sDate));

                calendar.set(Calendar.DAY_OF_WEEK, day); // day = Calendar.SUNDAY

                calendar.set(Calendar.HOUR_OF_DAY, 0);

                calendar.set(Calendar.MINUTE, 0);

                calendar.set(Calendar.SECOND, 0);

                calendar.add(Calendar.DATE, 7);

                dateFormat.format(calendar.getTime());

                try {

                    System.out.println("try (inner)...");

                    System.out.println("new Timestamp(calendar.getTime().getTime())): " +

                                      new Timestamp(calendar.getTime().getTime()));

                    result = new Date(new Timestamp(calendar.getTime().getTime())); // Code fails here.

                    return result;

                } catch (SQLException e) {

                    System.out.println("catch (SQLException e)...");

                    e.printStackTrace();

                }

                return null;

            } catch (ParseException e) {

                System.out.println("catch (ParseException e)...");

                e.printStackTrace();

            }

            return null;

        }

        return null;

    }

Here is the output:

try...

try (inner)...

new Timestamp(calendar.getTime().getTime())): 2013-12-29 00:00:00.0

catch (SQLException e)...

java.sql.SQLException: Initialization failed

  at oracle.sql.DATE.<init>(DATE.java:237)

  at oracle.jbo.domain.Date.<init>(Date.java:378)

James

This post has been answered by vinaykumar2 on Dec 27 2013
Jump to Answer

Comments

top.gun

Are you naming your controlfile ctl2.dat ?

Are you using the Oracle linux account, or the root account?

saam
Answer

Hi

7144389e-3944-4d5c-830e-46539d2d9971 wrote:

I got following error while creating database via script in linux. does anyone have any idea about this error.

ERROR at line 1:
ORA-01501: CREATE DATABASE failed
ORA-00200: control file could not be created
ORA-00202: control file: '/home/core/Databases/ControlFile/ctl2.dat'
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 13: Permission denied

Check the permissions on the directory for the user that is creating the database. That should solve your issue.

Regards

Adnan

Marked as Answer by 2650954 · Sep 27 2020
ASulthan

Hi

Check with you directory permission

1 - 3
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jan 24 2014
Added on Dec 26 2013
3 comments
8,980 views