Skip to Main Content

Java APIs

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!

Questions about the Calendar/Date class,BUG?

User_IZ661Oct 28 2021

My English is poor, but I hope to describe it clearly
precondition: JDK 1.8
I need to create a tool class to handle the date: convert the input string to the date N days ago
Several of Date's constructors were found to be out of date during use: "@deprecated" , so I chose "Date(long date)" , but found problems with the handling of February
This method is to process strings into dates

public static Date stringToDate(String str) {
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
Date date = null;
try {
date = format.parse(str);
} catch (ParseException e) {
e.printStackTrace();
}

return date;

}

Use "Date(long date)" (error)

public static Date getNDays(String str, int n) {
Calendar init = Calendar.getInstance();
init.set(1970,01,01,00,00,00);

Calendar calendar = Calendar.getInstance();
Date date = DateUtil.stringToDate(str);
calendar.setTime(date);
calendar.add(Calendar.DATE, -n);
calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) + 1);

long begin = init.getTimeInMillis();
long now = calendar.getTimeInMillis();

return new Date(now - begin);

}

falseResult.JPG
use "Date(int year, int month, int date, int hrs, int min, int sec)" but @deprecated (true)

public static Date getNDays(String str, int n) {
Calendar calendar = Calendar.getInstance();
Date date = DateUtil.stringToDate(str);

calendar.setTime(date);
calendar.add(Calendar.DATE, -n);

return new Date(
        calendar.get(Calendar.YEAR) - 1900,
        calendar.get(Calendar.MONTH),
        calendar.get(Calendar.DAY\_OF\_MONTH),
        0,
        0,
        0

 );
}

trueResult.JPGI hope to receive a reply,tanks!
email: 1710252399@vip.henu.edu.cn

Comments

SH_INT

There is no scripting support in EPBCS Data Management that would allow you to integrate any calls to the Salesforce REST API. So no.

DayalanP

Curious, cant we use a scripting language (Groovy) + REST API to get the data from Salesforce and load into EPBCS?

SH_INT

The scripting model in the Cloud EPM application is extremely limited, presumably for security reasons. Cloud Data Management has no scripting support outside of SQL scripting in mappings and although EPBCS does support Groovy this is limited to use in business rules and the EPBCS object libraries.

JohnGoodwin

I think there are two parts to this, the first is there currently is no direct integration to Salesforce, it may happen in the future but as it is not owned by Oracle then it is not going to be high priority.

The second is that it can be achieved outside of the cloud instance with solutions like Oracle Integration Cloud or onecloud.io or through custom scripting.

Cheers

John

1 - 5

Post Details

Added on Oct 28 2021
0 comments
310 views