MCPcopy Create free account
hub / github.com/MenoData/Time4J / toXML

Method toXML

sqlxml/src/main/java/net/time4j/xml/XMLAdapter.java:272–302  ·  view source on GitHub ↗
(
        ChronoDisplay tsp,
        int tz
    )

Source from the content-addressed store, hash-verified

270 }
271
272 private static XMLGregorianCalendar toXML(
273 ChronoDisplay tsp,
274 int tz
275 ) {
276
277 PlainDate date = tsp.get(PlainDate.COMPONENT);
278 int year = date.getYear();
279 int month = date.getMonth();
280 int dom = date.getDayOfMonth();
281
282 PlainTime time = tsp.get(PlainTime.COMPONENT);
283 int hour = time.getHour();
284 int minute = time.getMinute();
285 int second = tsp.get(PlainTime.SECOND_OF_MINUTE); // LS
286 int nano = time.getNanosecond();
287
288 DatatypeFactory factory = getXMLFactory();
289
290 if ((nano % MIO) == 0) {
291 int millis = nano / MIO;
292 return factory.newXMLGregorianCalendar(
293 year, month, dom, hour, minute, second, millis, tz);
294 } else {
295 BigInteger y = BigInteger.valueOf(year);
296 BigDecimal f =
297 BigDecimal.valueOf(nano).setScale(9, UNNECESSARY).divide(MRD_D, UNNECESSARY);
298 return factory.newXMLGregorianCalendar(
299 y, month, dom, hour, minute, second, f, tz);
300 }
301
302 }
303
304 //~ Innere Klassen ----------------------------------------------------
305

Callers 2

fromMethod · 0.80
fromMethod · 0.80

Calls 9

getYearMethod · 0.95
getMonthMethod · 0.95
getDayOfMonthMethod · 0.95
getHourMethod · 0.95
getMinuteMethod · 0.95
getNanosecondMethod · 0.95
getXMLFactoryMethod · 0.95
getMethod · 0.65
valueOfMethod · 0.45

Tested by

no test coverage detected