Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateFormatter not clear about what object it needs #1003

Open
CubBossa opened this issue Dec 8, 2023 · 3 comments
Open

DateFormatter not clear about what object it needs #1003

CubBossa opened this issue Dec 8, 2023 · 3 comments

Comments

@CubBossa
Copy link

CubBossa commented Dec 8, 2023

The following test code fails, while both Instant.now() and LocalDateTime.now() implement TemporalAccessor and should theoretically work

        MiniMessage mm = MiniMessage.miniMessage();
        assertEquals(
                mm.deserialize("<date:'mm'>", Formatter.date("date", LocalDateTime.now())),
                mm.deserialize("<date:'mm'>", Formatter.date("date", Instant.now()))
        );
org.opentest4j.AssertionFailedError: 

Expected :TextComponentImpl{content="28", style=StyleImpl{obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, color=null, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}

Actual   :TextComponentImpl{content="<date:'mm'>", style=StyleImpl{obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, color=null, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}
@Pablete1234
Copy link

This issue is a duplicate of an already closed one, see #952 (comment)

@CubBossa
Copy link
Author

CubBossa commented Dec 9, 2023

Alright thx, sorry for the duplicate. Maybe as requested in the other issue, there could be some accessible information on it, like producing an error or putting it into the docs of the method. Since Instant implements TemporalAccessor you would assume that it would work.

@kezz
Copy link
Member

kezz commented Dec 9, 2023

It generally boils down to just knowing that the that format you're writing is being backed by a date object that can provide the temporal information you would want. Perhaps we could be clearer in the JavaDocs, or throw a warning or something? I'll leave this issue open for that.

@kezz kezz changed the title Bug in DateFormatter DateFormatter not clear about what object it needs Dec 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants