Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#405 method for date #510

Closed
wants to merge 2 commits into from
Closed

#405 method for date #510

wants to merge 2 commits into from

Conversation

rgseyvie
Copy link

Support date placeholder in comparison. Though a better way is to modify Diff and configuration, it is more complicated.

current date, modify days and hours
add a method dateReplace, convert date placeholder in json to date string
int numSymbolIndex = replaceSub.indexOf("#");
if (replaceSub.contains("HOURS#")){
if (replaceSub.contains("+")){
time = df.format(new Date(date.getTime() + modifiedNum*60*60*1000));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaUtilDate: Date has a bad API that leads to bugs; prefer java.time.Instant or LocalDate. (details)

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

int numSymbolIndex = replaceSub.indexOf("#");
if (replaceSub.contains("HOURS#")){
if (replaceSub.contains("+")){
time = df.format(new Date(date.getTime() + modifiedNum*60*60*1000));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaUtilDate: Date has a bad API that leads to bugs; prefer java.time.Instant or LocalDate. (details)

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

}
else{
if (replaceSub.contains("+")){
time = df.format(new Date(date.getTime() + modifiedNum*24*60*60*1000));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaUtilDate: Date has a bad API that leads to bugs; prefer java.time.Instant or LocalDate. (details)

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

}
else{
if (replaceSub.contains("+")){
time = df.format(new Date(date.getTime() + modifiedNum*24*60*60*1000));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaUtilDate: Date has a bad API that leads to bugs; prefer java.time.Instant or LocalDate. (details)

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]


//check if date placeholder exists
if (replaceIndex >= 0){
Date date = new Date();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaUtilDate: Date has a bad API that leads to bugs; prefer java.time.Instant or LocalDate. (details)

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

time = df.format(new Date(date.getTime() + modifiedNum*60*60*1000));
}
else if(replaceSub.substring(numSymbolIndex+1, numSymbolIndex+2).equals("-")){
time = df.format(new Date(date.getTime() - modifiedNum*60*60*1000));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaUtilDate: Date has a bad API that leads to bugs; prefer java.time.Instant or LocalDate. (details)

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

time = df.format(new Date(date.getTime() + modifiedNum*60*60*1000));
}
else if(replaceSub.substring(numSymbolIndex+1, numSymbolIndex+2).equals("-")){
time = df.format(new Date(date.getTime() - modifiedNum*60*60*1000));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaUtilDate: Date has a bad API that leads to bugs; prefer java.time.Instant or LocalDate. (details)

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

time = df.format(new Date(date.getTime() + modifiedNum*24*60*60*1000));
}
else if(replaceSub.substring(numSymbolIndex+1, numSymbolIndex+2).equals("-")){
time = df.format(new Date(date.getTime() - modifiedNum*24*60*60*1000));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaUtilDate: Date has a bad API that leads to bugs; prefer java.time.Instant or LocalDate. (details)

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

time = df.format(new Date(date.getTime() + modifiedNum*24*60*60*1000));
}
else if(replaceSub.substring(numSymbolIndex+1, numSymbolIndex+2).equals("-")){
time = df.format(new Date(date.getTime() - modifiedNum*24*60*60*1000));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaUtilDate: Date has a bad API that leads to bugs; prefer java.time.Instant or LocalDate. (details)

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

String format = replaceSub.substring(formatIndex, replaceSub.length()-1);
df= new SimpleDateFormat(format);
df.setTimeZone(TimeZone.getTimeZone("GMT"));
time = df.format(new Date(date.getTime()));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaUtilDate: Date has a bad API that leads to bugs; prefer java.time.Instant or LocalDate. (details)

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

String format = replaceSub.substring(formatIndex, replaceSub.length()-1);
df= new SimpleDateFormat(format);
df.setTimeZone(TimeZone.getTimeZone("GMT"));
time = df.format(new Date(date.getTime()));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JavaUtilDate: Date has a bad API that leads to bugs; prefer java.time.Instant or LocalDate. (details)

(at-me in a reply with help or ignore)


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@lukas-krecan
Copy link
Owner

Hi, thanks. As I have written here, can you please add links how is it solve in the libraries like Wiremock?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants