Skip to content

Conversation

@marcvk
Copy link
Contributor

@marcvk marcvk commented Aug 24, 2024

I've added support java.util.Date. I've added the same tests as for LocalDateTime and all tests pass successfully. Let me know if anything else is needed.

@lihaoyi
Copy link
Member

lihaoyi commented Aug 24, 2024

@marcvk can you run the autoformatter to get ci / check-formatting to pass. Should be instructions in the readme

marcvk added 2 commits August 25, 2024 10:21
…matAll __.sources + "scalasql[2.13.12].test" + generateTutorial + generateReference

to fix formatting (a.o.)
@marcvk
Copy link
Contributor Author

marcvk commented Aug 25, 2024

@lihaoyi I found that statement in the developer reference doc, is that what you meant?

@lihaoyi
Copy link
Member

lihaoyi commented Aug 25, 2024

Should be! Lets run CI again and see if it worked

@lihaoyi lihaoyi merged commit 3aa29ff into com-lihaoyi:main Aug 25, 2024
@lihaoyi
Copy link
Member

lihaoyi commented Aug 25, 2024

@marcvk tagged 0.1.7 if youd like to begin using it

@marcvk
Copy link
Contributor Author

marcvk commented Aug 25, 2024

thnx!

myLocalDate = LocalDate.parse("2023-12-20"),
myLocalTime = LocalTime.parse("10:15:30"),
myLocalDateTime = LocalDateTime.parse("2011-12-03T10:15:30"),
myUtilDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS").parse("2011-12-03T10:15:30.000"),

Choose a reason for hiding this comment

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

Should we use SimpleDateFormat here ?

There are instances where java.text.SimpleDateFormat is used to parse dates. A better approach is to use java.time.format.DateTimeFormatter from the modern Java Time API (java.time) introduced in Java 8, which is thread-safe, more flexible, and offers better support for various date/time formats.

We could also convert from LocalDateTime

import java.time.format.DateTimeFormatter
import java.time.{LocalDateTime, ZoneId, ZoneOffset, ZonedDateTime}
import java.util.Date

val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")
val date = Date.from(
  LocalDateTime.parse("2023-11-12 03:22:41", formatter)
    .toInstant(
      ZonedDateTime.now(ZoneId.systemDefault()).getOffset
    )
)

println(date)

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.

3 participants