# JiBX: <format> Element

JiBX Basics
Overview
Flexibility
Performance
Clean code
News and Status
User Comments
Sponsors
Bugs
Getting Started
Binding Tutorial
A basic binding
Binding extras
Structure mapping
Collections
Using mappings
Advanced binding
Method hooks
Custom code
Binding Compiler
Binding on Load
Runtime
JiBX Extras
Building JiBX
Schema Compatibility
Mailing Lists
FAQ
Contributing
License
Binding Definition
Definition details
Definition contexts
Conversions
XML summary
<binding> element
<include> element
<format> element
<namespace> element
<mapping> element
<value> element
<structure> element
<collection> element
Attribute groups
Usage API
Runtime JavaDocs
Subprojects
Generator Tools
JibxSoap
Xsd2Jibx

### <format> Element Definition

The format element defines a conversion between some primitive or object type and the text representation used for that type. Any type with a format defined can be used with simple element (one with no child elements), text, or attribute values. During unmarshalling, the text content of the element or attribute is passed to the deserializer defined for that format, which returns a value of the appropriate type. During marshalling, the typed value is passed to the serializer for that format, which returns a text string used as the element content or attribute value.

This flexibility for conversion handling is also available without using a format element definition, by directly specifying the serializer and/or deserializer in a value definition. The advantage to using a format definition is that it can be easily reused. There are two ways of doing this. When a format element does not have a label attribute, it automatically becomes the default for values of the associated type. When a format element is defined with a label, that label can be used to reference it as needed.

The format element supports a pair of unique attributes along with one common attribute group, listed below.

#### Attributes

label | The label for this format. If supplied, the format can only be used when referenced by label. If not supplied, this format automatically becomes the default for handling the specified type within the context. As of JiBX 1.1, the value of this attribute is interpreted as namespace qualified.
type | This required attribute gives the fully qualified class name or the primitive type for the values handled by this format. For instance, for a format handling instances of the `java.util.Date` class this would be 'java.util.Date', and for one handling `int` primitive values it would be 'int'.
string | Attributes from the string group set the default conversion of a value type for all contained elements. See the string attribute group description for usage details.

format elements are subject to the restriction that labels must be unique, and unlabeled formats with the same type cannot be defined in the same context.