Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Consider an easier date adjuster #286

jodastephen opened this Issue · 7 comments

2 participants

Stephen Colebourne Roger Riggs
Stephen Colebourne

TemporalAdjuster is based on the low level Temporal, whereas most adjustments want to be written for LocalDate. Consider the following which may help:

     * Obtains a {@code TemporalAdjuster} that wraps a date adjuster.
     * <p>
     * The {@code TemporalAdjuster} is based on the low level {@code Temporal} interface.
     * This method allows an adjustment from {@code LocalDate} to {@code LocalDate}
     * to be wrapped to match the temporal-based interface.
     * @return the temporal adjuster wrapping on the date adjuster, not null
    public static TemporalAdjuster ofDateAdjuster(UnaryOperator<LocalDate> adjuster) {
        return (temporal) -> {
            LocalDate input = LocalDate.from(temporal);
            LocalDate output = adjuster.apply(input);
            return temporal.with(output);

Note, its not certain that this necessarily helps, or whether it should be hidden internally as part of a streams API.

Roger Riggs

What exceptions can ofDateAdjuster throw?

Stephen Colebourne

None. The returned adjuster might throw exceptions.

Still not sure that this is worth it yet though.

Stephen Colebourne

I think this is worth doing, as pretty much all implementations I can foresee in my day job are date-based, and this method makes writing them significantly easier.

Roger Riggs

How would it be used? It might lead to adjusters that make incorrect assumptions that are ISO biased, like the days in months, etc.
I don't it as that valuable.

Stephen Colebourne

I've pointed out many times before that running algorithms or manipulations on dates in an arbitrary/unknown calendar system is risky and likely to go wrong, due to the wide variation in calendar systems. Most business applications (what Java is principally used for) use ISO for algorithms, so making it easier to write correct ISO adjusters is a good thing, not a bad one.

The method would be used to help users write adjusters.

public static TemporalAdjuster TWEAKER = TemporalAdjuster.ofDateAdjuster(date -> { ... });
Roger Riggs


Stephen Colebourne jodastephen was assigned
Stephen Colebourne jodastephen closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.