All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.threetenjaxb.core.MonthAsTextXmlAdapter Maven / Gradle / Ivy

The newest version!
package io.github.threetenjaxb.core;

import jakarta.xml.bind.annotation.adapters.XmlAdapter;

import java.time.Month;

/**
 * {@code XmlAdapter} mapping JSR-310 {@code Month} to ISO proleptic month string
 * 

* Month string interpretation details (transformed to a string): *

    *
  • {@link java.time.Month#of(int)}
  • *
  • {@link java.time.Month#getValue()}
  • *
*

* This adapter is suitable for {@code xsd:gMonth} types. * * @see jakarta.xml.bind.annotation.adapters.XmlAdapter * @see java.time.Month */ public class MonthAsTextXmlAdapter extends XmlAdapter { @Override public Month unmarshal(String stringValue) { return stringValue != null ? Month.of(Integer.parseInt(stringValue)) : null; } @Override public String marshal(Month value) { return value != null ? Integer.toString(value.getValue()) : null; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy