So, moving along from the absolute basics, I will now demonstrate how to add an adapter for formatting.
We had a kennel class which contained a list of puppies. Each puppy has a birthday and a timestamp when it arrived in the kennel. These are both of the type XMLGregorianCalendar but I would rather have use Joda LocalDate and LocalDateTime. Therefore I add an adapter which is called when the contents of the <birthday> and <timestamp> tags are unmarshalled.
The DateAdapter.java has two static methods, unmarshal and marshal, which convert a string to a LocalDate and vice versa respectively.
Run it to generate the code:
The DateAdapter generates an Adapter1.java
We had a kennel class which contained a list of puppies. Each puppy has a birthday and a timestamp when it arrived in the kennel. These are both of the type XMLGregorianCalendar but I would rather have use Joda LocalDate and LocalDateTime. Therefore I add an adapter which is called when the contents of the <birthday> and <timestamp> tags are unmarshalled.
The DateAdapter.java has two static methods, unmarshal and marshal, which convert a string to a LocalDate and vice versa respectively.
Run it to generate the code:
xjc ../resources/puppy/kennel.xsd -p com.ojha.jaxb.kennel.generated