Skip to content

Additional wordBased method on AmountFormats#373

Merged
jodastephen merged 1 commit into
mainfrom
period-duration
Aug 15, 2025
Merged

Additional wordBased method on AmountFormats#373
jodastephen merged 1 commit into
mainfrom
period-duration

Conversation

@jodastephen

@jodastephen jodastephen commented Aug 15, 2025

Copy link
Copy Markdown
Member

Allow PeriodDuration to be directly formatted
Also remove trailing whitespace in yaml
See #269

Summary by CodeRabbit

  • New Features
    • Added word-based formatting support for PeriodDuration, aligning output with existing period/duration formats.
  • Documentation
    • Updated ISO-8601 formatting references to include PeriodDuration.
  • Tests
    • Expanded coverage to validate PeriodDuration formatting parity and added locale checks for Romanian and Persian.
  • Chores
    • CI workflow now runs on pushes, pull requests, and a scheduled cadence, improving automation coverage.

@jodastephen jodastephen requested a review from Copilot August 15, 2025 14:14
@coderabbitai

coderabbitai Bot commented Aug 15, 2025

Copy link
Copy Markdown

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Caution

Review failed

The pull request is closed.

Walkthrough

Expanded CI triggers to include push, pull_request, and schedule. Added a new AmountFormats overload to format PeriodDuration in a word-based manner by delegating to existing Period and Duration formatters. Tests updated to cover PeriodDuration and added locale constants for Romanian and Persian.

Changes

Cohort / File(s) Summary
CI Workflow Triggers
.github/workflows/build.yml
Added pull_request and schedule triggers alongside push; minor whitespace tweaks.
AmountFormats API Extension
src/main/java/org/threeten/extra/AmountFormats.java
Added public static String wordBased(PeriodDuration, Locale); Javadoc updated to mention PeriodDuration; delegates to existing wordBased(period/duration, locale).
Tests and Locale Coverage
src/test/java/org/threeten/extra/TestAmountFormats.java
Added tests for PeriodDuration-based formatting; introduced RO and FA Locale constants; aligned expected outputs and assertions across locales.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant AmountFormats
  participant PeriodDuration
  participant WordFormatter as Existing wordBased(period/duration)

  Caller->>AmountFormats: wordBased(PeriodDuration pd, Locale loc)
  AmountFormats->>PeriodDuration: getPeriod()
  AmountFormats->>WordFormatter: wordBased(period, loc)
  AmountFormats->>PeriodDuration: getDuration()
  AmountFormats->>WordFormatter: wordBased(duration, loc)
  AmountFormats-->>Caller: concatenated word-based string
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8–10 minutes

Poem

A rabbit taps the build at dawn,
New triggers hop and shuffle on.
Words for time, now joined in pair—
Period, Duration, a tidy affair.
RO, FA sing in chorus bright,
Tests nibble edge-cases right.
Ship it swift, ears high with delight!

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 54834ca and 1e5e529.

📒 Files selected for processing (3)
  • .github/workflows/build.yml (2 hunks)
  • src/main/java/org/threeten/extra/AmountFormats.java (2 hunks)
  • src/test/java/org/threeten/extra/TestAmountFormats.java (4 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch period-duration

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new convenience method to AmountFormats for formatting PeriodDuration objects directly in word-based format. Previously, users had to extract the period and duration components separately to use the existing wordBased method.

  • Adds a new wordBased method that accepts a PeriodDuration object and locale
  • Refactors test code to use constants for locale instances instead of inline new Locale() calls
  • Updates documentation to include PeriodDuration in the ISO-8601 format method description

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/main/java/org/threeten/extra/AmountFormats.java Adds new wordBased(PeriodDuration, Locale) method and updates documentation
src/test/java/org/threeten/extra/TestAmountFormats.java Adds locale constants and test assertion for the new method

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

* @param locale the locale to use
* @return the localized word-based format for the period-duration
*/
public static String wordBased(PeriodDuration periodDuration, Locale locale) {

Copilot AI Aug 15, 2025

Copy link

Choose a reason for hiding this comment

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

The method should include null parameter validation for both periodDuration and locale parameters to maintain consistency with the existing wordBased method behavior and prevent potential NullPointerExceptions.

Suggested change
public static String wordBased(PeriodDuration periodDuration, Locale locale) {
public static String wordBased(PeriodDuration periodDuration, Locale locale) {
Objects.requireNonNull(periodDuration, "periodDuration");
Objects.requireNonNull(locale, "locale");

Copilot uses AI. Check for mistakes.
Allow `PeriodDuration` to be directly formatted
Also remove trailing whitespace in yaml
See #269
@jodastephen jodastephen merged commit 1af9bdc into main Aug 15, 2025
8 of 9 checks passed
@jodastephen jodastephen deleted the period-duration branch August 15, 2025 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants