Skip to content

Add support for getZone on ReadableDateTime objects in Painless #31438

@alexandreblin

Description

@alexandreblin

Describe the feature:
A little context : I am trying to compute the difference in months between two dates in a scripted field.

I want to use the ChronoUnit.MONTHS.between() methods, which takes Java 8 date objects as parameters. But when getting dates from my document, I get JodaTime ReadableDateTime objects.

So I'm using the following to convert between JodaTime date object and Java 8 date objects :

var date = doc['subscribed_at'].value
Instant.ofEpochMilli(date.getMillis()).atZone(ZoneId.of(date.getZone().getID()))

However, according to the Painless API reference, getZone() is not whilelisted, which prevents me from converting the time properly by taking the timezone into account.

So, would it be possible to whitelist the getZone() method?
Or maybe I am missing something and there is a simpler way to do what I'm trying to do?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions