Add Minutes to datetime

Hi

I have search for a similar topic however the responses are far too technical for me to understand - I cannot write functions yet and don’t know how to use them.

there are these snippets of code that I don’t understand and I have no idea what to do with them - where to put them or how to make them work.

I use the functionality that is available in katalon at this stage. I use the manual view and I am still trying to figure out what I think is the Groovy script view. and I need to find stuff to copy and paste into there and hope like hell it works because I cannot write my own lines without looking at an example.

all I want to do is set text in a field - I am setting a datetime formatted ‘dd/MM/yy HH:mm’ with 10 minutes added.

how do I add the 10 minutes?

is there a simple way like it is in my mind to add 10 minutes to a datetime.

this might looks stupid but from what I have found - this is what I ended up with and well its not working and I don’t know what to do?

Date todaysDate = new Date()

def dateTime = todaysDate.format(‘dd-MM-yyyy HH:mm’)

WebUI.setText(findTestObject(‘Object Repository/Page_iCA Manage event/m.manage event elective notification date input’),
dateTime + 10.minutes)

I would really appreciate assistance. Thank you.

1 Like

If you do not make effort to learn programming, you would not be able to solve your problem.


See

Thanks for your assistance - I am learning as I am doing it - its been 8 months and only about 1 of those months time has been spent on automation - the learning is going very slow and I am sure i have years to go but between work life and home life to sit down with a a book and study - at work I am working and at home I am working or doing other neccessary things - so I’m learning as I can and only when I am busy with katalon - if I am not physically busy with katalon then there is no time for it - I am the only manual tester in this company and my time is very limited - so I do the best I can. I’m going into this by myself on my own time, there is currently no company backing for it.

Thanks but I cannot use this site - I don’t what to do with that code - how do you put it in your code so that it works?

import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

LocalDateTime timestamp = LocalDateTime.now()
LocalDateTime tenMinutesLater = timestamp.plusMinutes(10)

DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm")
String s = dtf.format(timestamp)
String t = dtf.format(tenMinutesLater)

println "s = " + s
println "t = " + t

This gives me:

2023-12-05 17:14:13.002 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2023-12-05 17:14:13.003 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/LocalDateTime
s = 05-12-2023 17:14
t = 05-12-2023 17:24
2023-12-05 17:14:13.140 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/LocalDateTime

Hi kazurayam

I actually understand what you just sent - I have implemented it

import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

LocalDateTime dateTime = LocalDateTime.now()

LocalDateTime dateMinutes = timestamp.plusMinutes(10)

DateTimeFormatter dtf = DateTimeFormatter.ofPattern(“dd-MM-yyyy HH:mm”)

String notificationDate = dtf.format(dateMinutes)

but I am getting this error:
2023-12-05 10:34:49.829 ERROR c.k.k.core.main.WSVerificationExecutor - ? Verification FAILED.
Reason:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WSVerification1701765289444: 20: unable to resolve class LocalDateTime
@ line 20, column 15.
LocalDateTime dateTime = LocalDateTime.now()
^

WSVerification1701765289444: 22: unable to resolve class LocalDateTime
@ line 22, column 15.
LocalDateTime dateMinutes = timestamp.plusMinutes(10)
^

WSVerification1701765289444: 24: unable to resolve class DateTimeFormatter
@ line 24, column 19.
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(‘dd-MM-yyyy HH:mm’)
^

3 errors

I also have this installed DateTime Keywords - but there is no information or examples of how to use it - there is no information on this plugin that I can find useful. like commands that you can use with it and how to use them.

there is no information here

and the document page looks like this

I made a Test Case just the same as yours, and ran it.

It ran just fine. I do not see any error on my machine.

This message looks surprising to me.

WSVerificationExecutor? — What is it? I do not see what this class is, and why it is involved.

“WS” in Katalo Studio stands for “Web Service”.

Do you have any idea?

Your code declares import java.time.LocalDateTime but the Groovy compiler warned unable to resolve the class. Totally abnormal. There must be something very bad in your environment.

apparently I need to install java development toolkit and add the library to project settings
I have followed all the instructions but it does not want to work and now katalon cannot even build my test cases


so I do not know how to install the java library so that it works and I can use those java functions

???

The java.time.LocalDateTime is included in the jdk of Java8 which is bundled in Katalon Studio v8.x.x. You do not need to add any external jar into Katalon Studio in order to resolve java.time.LocalDateTime.

You mentioned jrt-fs.jar . How have you got to know this? Why do you want to add it? Any reference?


Edit: I found the source of the term jrt:

https://openjdk.org/jeps/220

New URI scheme for naming stored modules, classes, and resources

To address the above three problems a new URL scheme, jrt , can be used to name the modules, classes, and resources stored in a run-time image without revealing the internal structure or format of the image.

Google Bard


I will try and istall java8

I see. Google Bard is fooling you.

No. Totally wrong. I sighed.

Google Bard knows nothing trustworthy, but it is clever enough to pretend that it knows something.

Please enjoy chatting with it and waste your time.

well I cannot remove that Jar file now and my project does not want to build - so now I am unistalling and re-installing studio, I have inatlled java 8 - or at least I think I have because what I read while its installing doesn’t seem to match what I downloaded so I will see what happens

Would you agree with closing this topic?

Yes - if I don’t come right and I cannot get Katalon do do what i need it to do - I am going to have stop trying to convice my company that its going to work for them - If I cannot prove its working then its a no go

you can close it - I getting tired of this issue

@vu.tran
@Elly_Tran

Will you help @katalon9 ?

Don’t worry

I re-installed Katalon - my entire project is gone - weeks worth of work - and I have no idea where it is to get it back into studio.

Don’t you have any backup of the project?

Lesson learned — you should always take a backup of your project. No exception. If you don’t, you should not blame others when your project is gone away.

1 Like

Default folder for new projects is usually C:\Users\yourusername\Katalon Studio.
I don’t see how you’d lose a project unless you’ve accidentally deleted it… if so, perhaps check Recycle Bin first?
If still not found, search for a Katalon filetype on the hard drive, like .prj or .rs
Good luck!
Just to add though - if your company is not serious enough to dedicate some time to a proof of concept and continued support then perhaps it’s not the right fit? Automation needs upfront investment and planning to get right

1 Like

Hi,

Sorry for the late response. Please try to follow @Dan_Bown suggestion. If you are an Enterprise user, please help raise a ticket over Katalon Help Center for better support. Thank you!

1 Like