PageSourceSearch

https://www.joda.org/joda-convert/

html joda.org collected 2026-10-01 10:15:21 UTC 14,295 bytes, 315 lines download raw bytes

1
2<!DOCTYPE html>
3<!--
4 Generated by Apache Maven Doxia at 2024-10-06
5 Rendered using Reflow Maven Skin 1.2 (http://andriusvelykis.github.io/reflow-maven-skin)
6-->
7<html  xml:lang="en" lang="en">
8
9	<head>
10		<meta charset="UTF-8" />
11		<title>Joda-Convert - Home</title>
12		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
13		<meta name="description" content="" />
14		<meta http-equiv="content-language" content="en" />
15
16		<link href="//netdna.bootstrapcdn.com/bootswatch/2.3.2/cosmo/bootstrap.min.css" rel="stylesheet" />
17		<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-responsive.min.css" rel="stylesheet" />
18		<link href="./css/bootswatch.css" rel="stylesheet" />
19		<link href="./css/reflow-skin.css" rel="stylesheet" />
20
21
22
23		<link href="./css/site.css" rel="stylesheet" />
24		<link href="./css/print.css" rel="stylesheet" media="print" />
25
26		<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
27		<!--[if lt IE 9]>
28			
28<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
28
29		<![endif]-->
30
31
32<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"/>
33        <link rel="author" href="https://plus.google.com/113137868744510231215"/>
34
35		<!-- Google Analytics -->
36		
36<script type="text/javascript">
37
38			var _gaq = _gaq || [];
39			_gaq.push(['_setAccount', 'UA-1425975-4']);
40			_gaq.push(['_trackPageview']);
41
42			(function() {
43				var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
44				ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
45				var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
46			})();
47
48		</script>
48
49		</head>
50
51	<body class="page-index project-joda-convert" data-spy="scroll" data-offset="60" data-target="#toc-scroll-target">
52
53		<div class="navbar navbar-fixed-top">
54			<div class="navbar-inner">
55				<div class="container">
56					<a class="btn btn-navbar" data-toggle="collapse" data-target="#top-nav-collapse">
57						<span class="icon-bar"></span>
58						<span class="icon-bar"></span>
59						<span class="icon-bar"></span>
60					</a>
61					<a class="brand" href="index.html">Joda-Convert</a>
62					<div class="nav-collapse collapse" id="top-nav-collapse">
63						<ul class="nav pull-right">
64							<li class="dropdown active">
65								<a href="#" class="dropdown-toggle" data-toggle="dropdown">Documentation <b class="caret"></b></a>
66								<ul class="dropdown-menu">
67									<li class="active"><a href="" title="Home">Home</a></li>
68									<li ><a href="userguide.html" title="User guide">User guide</a></li>
69									<li ><a href="apidocs/index.html" title="Javadoc">Javadoc</a></li>
70									<li ><a href="licenses.html" title="License">License</a></li>
71								</ul>
72							</li>
73							<li class="dropdown">
74								<a href="#" class="dropdown-toggle" data-toggle="dropdown">Releases <b class="caret"></b></a>
75								<ul class="dropdown-menu">
76									<li ><a href="changes-report.html" title="Release notes">Release notes</a></li>
77									<li ><a href="dependency-info.html" title="Dependency info">Dependency info</a></li>
78									<li ><a href="download.html" title="Download">Download</a></li>
79								</ul>
80							</li>
81							<li class="dropdown">
82								<a href="#" class="dropdown-toggle" data-toggle="dropdown">Development <b class="caret"></b></a>
83								<ul class="dropdown-menu">
84									<li ><a href="https://github.com/JodaOrg/joda-convert" title="GitHub" class="externalLink">GitHub</a></li>
85									<li ><a href="https://github.com/JodaOrg/joda-convert/issues" title="Bugs/Issues" class="externalLink">Bugs/Issues</a></li>
86									<li ><a href="surefire.html" title="Test results">Test results</a></li>
87								</ul>
88							</li>
89							<li class="dropdown">
90								<a href="#" class="dropdown-toggle" data-toggle="dropdown">Joda <b class="caret"></b></a>
91								<ul class="dropdown-menu">
92									<li ><a href="../" title="Home">Home</a></li>
93									<li ><a href="../joda-beans/" title="Beans">Beans</a></li>
94									<li ><a href="../joda-money/" title="Money">Money</a></li>
95									<li ><a href="../joda-time/" title="Time">Time</a></li>
96								</ul>
97							</li>
98							<li class="dropdown">
99								<a href="#" class="dropdown-toggle" data-toggle="dropdown">For Enterprise <b class="caret"></b></a>
100								<ul class="dropdown-menu">
101									<li ><a href="enterprise.html" title="Tidelift">Tidelift</a></li>
102								</ul>
103							</li>
104						</ul>
105					</div><!--/.nav-collapse -->
106				</div>
107			</div>
108		</div>
109
110	<div class="container">
111
112	<!-- Masthead
113	================================================== -->
114
115	<header>
116	</header>
117
118	<div class="main-body">
119	<div class="row columns columns3">
120		<div class="span4">
121			<h2 id="About"><i></i> About</h2>
122<p><b>Joda-Convert</b> tackles the problem of round-trip Object to String conversion.</p>
123<p>A common problem in serialization, particularly when working with textual formats like JSON, is that of converting simple objects to and from strings. Joda-Convert addresses this without getting caught up in the wider problem of Object to Object transformation.</p>
124<p>Joda-Convert is licensed under the business-friendly <a href="licenses.html">Apache 2.0 licence</a>.</p>
125<section>    
126</section>
127		</div>
128		<div class="span4">
129			<h2 id="Features"><i></i> Features</h2>
130<p>A selection of key features:</p>
131<ul> 
132 <li>Round-trip Object to String</li> 
133 <li>Conversions defined by annotations or by implementing a simple interface</li> 
134 <li>Very simple to use</li> 
135 <li>No dependencies</li> 
136</ul>
137<section>    
138</section>
139		</div>
140		<div class="span4">
141			<h2 id="Documentation"><i></i> Documentation</h2>
142<p>Various documentation is available:</p>
143<ul> 
144 <li>The helpful <a href="userguide.html">user guide</a></li> 
145 <li>The <a href="apidocs/index.html">Javadoc</a></li> 
146 <li>The <a href="changes-report.html">change notes</a> for each release</li> 
147 <li>The <a class="externalLink" href="https://github.com/JodaOrg/joda-convert">GitHub</a> source repository</li> 
148</ul>
149		</div>
150	</div>
151	<div class="row">
152	</div>
153	<div class="row columns columns1">
154		<div class="span12">
155			<h2 id="Why_Joda_Convert.3F"><i></i> Why Joda Convert?</h2>
156<p>Joda-Convert is a small, highly-focussed library, tackling a problem that the JDK should solve - providing round-trip conversion between Objects and Strings.</p>
157<div class="source"> 
158 <pre>
159  // conversion to String
160  <b>String str = <a href="apidocs/org.joda.convert/org/joda/convert/StringConvert.html">StringConvert</a>.INSTANCE.convertToString(foo);</b>
161
162  // conversion from String
163  <b>Foo bar = StringConvert.INSTANCE.convertFromString(Foo.class, str);</b>
164</pre> 
165</div>
166<p>Joda-Convert supports two mechanisms of extending the list of supported conversions. The first is to write your own <a href="apidocs/org.joda.convert/org/joda/convert/TypedStringConverter.html">converter</a> implementing an interface. The second is to use annotations.</p>
167<p>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 <code>Currency</code> or <code>TimeZone</code>, already have methods to convert to and from a standard format String. Consider a <code>Distance</code> class:</p>
168<div class="source"> 
169 <pre>
170  <b>public class Distance {</b>
171    <b><a href="apidocs/org.joda.convert/org/joda/convert/FromString.html">@FromString</a></b>
172    <b>public static Distance parse(String str) { ... }</b>
173
174    <b><a href="apidocs/org.joda.convert/org/joda/convert/ToString.html">@ToString</a></b>
175    <b>public String getStandardOutput() { ... }</b>
176  <b>}</b>
177</pre> 
178</div>
179<p>As shown, the two methods may have any name. They must simply fulfil the required method signatures for conversion. The <code>FromString</code> annotation may also be applied to a constructor.</p>
180<p>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.</p>
181		</div>
182	</div>
183	<div class="row">
184	</div>
185	<div class="row">
186		<div class="span8">
187			<div class="body-content">
188				<section> 
189 <h2 id="Releases"><i></i> Releases</h2> 
190 <p>The 3.x branch (v3.0.1) is compatible with Java SE 21 or later.</p> 
191 <p>The 2.x branch (v2.2.4) is compatible with Java SE 6 or later.</p> 
192 <p>v3.x releases are compatible with v2.x releases, however the <code>module-info.class</code> file is always present, and the oldest development pre-release of JSR-310 is not recognized. v2.x releases are compatible with v1.x releases, with the exception that the direct Guava dependency is removed.</p> 
193 <p>Joda-Convert has no mandatory dependencies, however Guava and ThreeTen-Backport will be used if present.</p> 
194 <p>Available in the <a class="externalLink" href="https://search.maven.org/search?q=g:org.joda%20AND%20a:joda-convert&amp;core=gav">Maven Central repository</a>. <a class="externalLink" href="https://github.com/JodaOrg/joda-convert/releases">GitHub release bundles</a>.</p> 
195 <div class="source"> 
196  <pre><code class="language-xml">&lt;dependency&gt;
197  &lt;groupId&gt;org.joda&lt;/groupId&gt;
198  &lt;artifactId&gt;joda-convert&lt;/artifactId&gt;
199  &lt;version&gt;3.0.1&lt;/version&gt;
200&lt;/dependency&gt;
201</code></pre> 
202 </div> 
203 <p>Java module name: <code>org.joda.convert</code>.</p>    
204</section>
205			</div>
206		</div>
207		<div class="span4">
208			<div class="well sidebar">
209	<h3 id="For_Enterprise">For Enterprise</h3>
210<p><a class="externalLink" href="https://tidelift.com/subscription/pkg/maven-org-joda-joda-money?utm_source=maven-org-joda-joda-money&amp;utm_medium=referral&amp;utm_campaign=enterprise">Available as part of the Tidelift Subscription</a>.</p>
211<p>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.</p>
212<p>If you want the flexibility of open source and the confidence of commercial-grade software, this is for you. <a class="externalLink" href="https://tidelift.com/subscription/pkg/maven-org-joda-joda-convert?utm_source=maven-org-joda-joda-convert&amp;utm_medium=referral&amp;utm_campaign=enterprise">Learn more</a>.</p>
213<section>     
214</section>
215	<h3 id="Support">Support</h3>
216<p>Please use <a class="externalLink" href="https://stackoverflow.com/search?q=joda-convert">Stack Overflow</a> for general usage questions. GitHub <a class="externalLink" href="https://github.com/JodaOrg/joda-convert/issues">issues</a> and <a class="externalLink" href="https://github.com/JodaOrg/joda-convert/pulls">pull requests</a> should be used when you want to help advance the project.</p>
217<p>Any donations to support the project are accepted via <a class="externalLink" href="https://opencollective.com/joda">OpenCollective</a>.</p>
218<p>To report a security vulnerability, please use the <a class="externalLink" href="https://tidelift.com/security">Tidelift security contact</a>
218. Tidelift will coordinate the fix and disclosure.</p>
219			</div>
220		</div>
221	</div>
222	</div>
223
224	</div><!-- /container -->
225
226	<!-- Footer
227	================================================== -->
228	<footer class="well">
229		<div class="container">
230			<div class="row">
231				<div class="span2 bottom-nav">
232					<ul class="nav nav-list">
233						<li class="nav-header">Documentation</li>
234						<li class="active">
235							<a href="#" title="Home">Home</a>
236						</li>
237						<li >
238							<a href="userguide.html" title="User guide">User guide</a>
239						</li>
240						<li >
241							<a href="apidocs/index.html" title="Javadoc">Javadoc</a>
242						</li>
243						<li >
244							<a href="licenses.html" title="License">License</a>
245						</li>
246					</ul>
247				</div>
248				<div class="span2 bottom-nav">
249					<ul class="nav nav-list">
250						<li class="nav-header">Releases</li>
251						<li >
252							<a href="changes-report.html" title="Release notes">Release notes</a>
253						</li>
254						<li >
255							<a href="dependency-info.html" title="Dependency info">Dependency info</a>
256						</li>
257						<li >
258							<a href="download.html" title="Download">Download</a>
259						</li>
260					</ul>
261				</div>
262				<div class="span2 bottom-nav">
263					<ul class="nav nav-list">
264						<li class="nav-header">Development</li>
265						<li >
266							<a href="https://github.com/JodaOrg/joda-convert" title="GitHub" class="externalLink">GitHub</a>
267						</li>
268						<li >
269							<a href="https://github.com/JodaOrg/joda-convert/issues" title="Bugs/Issues" class="externalLink">Bugs/Issues</a>
270						</li>
271						<li >
272							<a href="surefire.html" title="Test results">Test results</a>
273						</li>
274					</ul>
275				</div>
276				<div class="span3 bottom-nav">
277					<ul class="nav nav-list">
278						<li class="nav-header">Reports</li>
279						<li >
280							<a href="project-info.html" title="Project Information">Project Information <i class="icon-chevron-right"></i></a>
281						</li>
282						<li >
283							<a href="project-reports.html" title="Project Reports">Project Reports <i class="icon-chevron-right"></i></a>
284						</li>
285					</ul>
286				</div>
287				<div class="span3 bottom-description">
288					<blockquote>Round-trip Object to String conversion for Java</blockquote>
289				</div>
290			</div>
291		</div>
292	</footer>
293
294	<div class="container subfooter">
295		<div class="row">
296			<div class="span12">
297				<p class="pull-right"><a href="#">Back to top</a></p>
298				<p class="copyright">Copyright &copy;2010-2024 <a href="https://www.joda.org">Joda.org</a>. All Rights Reserved.</p>
299				<p class="version-date"><span class="projectVersion">Version: 3.0.1. </span><span class="publishDate">Last Published: 2024-10-06. </span></p>
300				<p><a href="https://github.com/JodaOrg/reflow-maven-skin" title="Reflow Maven skin">Reflow Maven skin</a>.</p>
301			</div>
302		</div>
303	</div>
304
305	<!-- Le javascript
306	================================================== -->
307	<!-- Placed at the end of the document so the pages load faster -->
308	
308<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
308
309
310	
310<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
310
311
312	
312<script src="./js/reflow-skin.js"></script>
312
313
314	</body>
315</html>

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.