0

Till now i was using

val date = Instant.now(Clock.system(ZoneId.of("UTC")))

to generate the instant timestamp. Now I need to substitute it with the date that I want to specify for example "2021-05-03T00:00:00.000Z". When i insert it as a string into the function, the idea gives me the error "Type mismatch. Required: Instant! Found: String". I can't change the function as I have no such access to it. So i need to somehow turn this date into "Instant!" class.

this is how the function that i can't change looks like

    public TimeTZ(Instant timestamp, Boolean isLocal) {
        this.timestamp = timestamp;
        this.isLocal = isLocal;
    }

1 Answer 1

0
val date = Instant.parse("2021-05-03T00:00:00.000Z")

Converting a string to an Instant (or other typed value) is called parsing. So use the parse method of Instant.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks, wasnt able to look it up properly that method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.