- Notifications
You must be signed in to change notification settings - Fork24
Java library to enable conversion to and from standard string formats.
License
JodaOrg/joda-convert
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Joda-Convert is a small, highly-focussedlibrary, tackling a problem that the JDK should solve -providing round-trip conversion between Objects and Strings.It is not intended to tackle the wider problem of Object to Object transformation.
// conversion to StringStringstr =StringConvert.INSTANCE.convertToString(foo);// conversion from StringFoobar =StringConvert.INSTANCE.convertFromString(Foo.class,str);
Joda-Convert supports two mechanisms of extending the list of supported conversions.The first is to write your ownconverter implementing an interface.The second is to use annotations.
The ability of Joda-Convert to use annotations to define the conversion methods is a key difference from other projects.For example, most value classes, likeCurrency
orTimeZone
, already have methodsto convert to and from a standard format String.Consider aDistance
class annotated withFromString
andToString
:
publicclassDistance {@FromStringpublicstaticDistanceparse(Stringstr) { ... }@ToStringpublicStringgetStandardOutput() { ... }}
As shown, the two methods may have any name. They must simply fulfil the required method signatures for conversion.TheFromString
annotation may also be applied to a constructor.
When Joda-Convert is asked to convert between an object and a String, if there is no registered converterthen the annotations are checked. If they are found, then the methods are called by reflection.
Joda-Convert is licensed under the business-friendlyApache 2.0 licence.
Various documentation is available:
- Thehome page
- The helpfuluser guide
- TheJavadoc
- The change notes for thereleases
The 3.x branch is compatible with Java SE 21 or later.
The 2.x branch is compatible with Java SE 6 or later.
v2.x releases are compatible with v1.x releases, with the exception that the direct Guava dependency is removed.v3.x releases are compatible with v2.x releases, however themodule-info.class
file is always present,and the oldest development pre-release of JSR-310 is not recognized.
Joda-Convert hasno dependencies.
Available in theMaven Central repository.GitHub release bundles.
Available as part of the Tidelift Subscription.
Joda and the maintainers of thousands of other packages are working with Tidelift to deliver one enterprise subscription that covers all of the open source you use.
If you want the flexibility of open source and the confidence of commercial-grade software, this is for you.
Please useStack Overflow for general usage questions.GitHubissues andpull requestsshould be used when you want to help advance the project.
Any donations to support the project are accepted viaOpenCollective.
To report a security vulnerability, please use theTidelift security contact.Tidelift will coordinate the fix and disclosure.
- Update version (index.md, changes.xml)
- Commit and push
git push origin HEAD:refs/tags/release
- Code and Website will be built and released by GitHub Actions
Release from local:
- Turn off gpg "bc" signer
mvn clean release:clean release:prepare release:perform
About
Java library to enable conversion to and from standard string formats.