Skip to content

[StringHelpers] Add support for Calendar in dateFormat #1079

Done

Description

@LeBezout

Hi,

In com.github.jknack.handlebars.helper.StringHelpers for the dateFormat helper we can add the support for (the good old) Calendar as already exists for (the good old) Date :

Actual :

private TemporalAccessor toTemporalAccessor(final Object value) {
  if (value instanceof TemporalAccessor) {
	return (TemporalAccessor) value;
  } else if (value instanceof Date) {
	return ((Date) value).toInstant();
  } else {
	// ...
}

Proposal :

private TemporalAccessor toTemporalAccessor(final Object value) {
  if (value instanceof TemporalAccessor) {
	return (TemporalAccessor) value;
  } else if (value instanceof Date) {
	return ((Date) value).toInstant();
  } else if (value instanceof Calendar) {
	return ((Calendar) value).toInstant();
  } else {
	// ...
}

Activity

  1. yashdotdev13 commented on Nov 28, 2026

    @yashdotdev13
    Contributor

    Hi @LeBezout, Implemented Calendar support for the dateFormat helper in PR #1227.

    Added a regression test in DateFormatTest to verify formatting of java.util.Calendar instances.

    The new test passes. I also verified that the three failures in the existing DateFormatTest suite occur on the unmodified upstream code.

    Thanks!

  2. added a commit that references this issue on Nov 29, 2026
  3. added this to the 4.6.0 milestone on Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions