GithubHelp home page GithubHelp logo

darkflag / joda-convert Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jodaorg/joda-convert

0.0 2.0 0.0 642 KB

Java library to enable conversion to and from standard string formats.

Home Page: http://www.joda.org/joda-convert/

License: Apache License 2.0

Java 99.59% CSS 0.35% HTML 0.06%

joda-convert's Introduction

Joda-Convert

Joda-Convert provides a small set of classes to aid conversion between Objects and Strings. It is not intended to tackle the wider problem of Object to Object transformation.

// conversion to String
String str = StringConvert.INSTANCE.convertToString(foo);

// conversion from String
Foo bar = StringConvert.INSTANCE.convertFromString(Foo.class, str);

Joda-Convert supports two mechanisms of extending the list of supported conversions. The first is to write your own converter 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, like Currency or TimeZone, already have methods to convert to and from a standard format String. Consider a Distance class:

public class Distance {

  @FromString
  public static Distance parse(String str) { ... }

  @ToString
  public String getStandardOutput() { ... }

}

As shown, the two methods may have any name. They must simply fulfil the required method signatures for conversion. The FromString 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 converter then the annotations are checked. If they are found, then the methods are called by reflection.

Joda-Convert is licensed under the business-friendly Apache 2.0 licence.

Documentation

Various documentation is available:

Releases

Release 1.8.1 is the current latest release. This release is considered stable and worthy of the 1.x tag. It depends on Java SE 6 or later.

Available in the Maven Central repository

Support

Please use GitHub issues and Pull Requests for support.

joda-convert's People

Contributors

cjkent avatar jodastephen avatar rocketraman avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.