Here you can find the source of toDateTime()
public static Function<XMLGregorianCalendar, DateTime> toDateTime()
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import com.google.common.base.Function; import org.joda.time.DateTime; import javax.annotation.Nullable; import javax.xml.datatype.XMLGregorianCalendar; public class Main { private static final Function<XMLGregorianCalendar, DateTime> xmlToJoda = new Function<XMLGregorianCalendar, DateTime>() { @Nullable// w ww . j a v a 2 s . co m @Override public DateTime apply(@Nullable XMLGregorianCalendar input) { return input == null ? null : new DateTime(input.toGregorianCalendar().getTime()); } }; public static Function<XMLGregorianCalendar, DateTime> toDateTime() { return xmlToJoda; } public static DateTime toDateTime(@Nullable XMLGregorianCalendar time) { return xmlToJoda.apply(time); } }