Example usage for javax.xml.datatype XMLGregorianCalendar getFractionalSecond

List of usage examples for javax.xml.datatype XMLGregorianCalendar getFractionalSecond

Introduction

In this page you can find the example usage for javax.xml.datatype XMLGregorianCalendar getFractionalSecond.

Prototype

public abstract BigDecimal getFractionalSecond();

Source Link

Document

Returns fractional seconds.

Usage

From source file:Main.java

public static BigDecimal getSeconds(XMLGregorianCalendar x) {
    BigDecimal fractional = x.getFractionalSecond();
    if (fractional == null)
        fractional = BigDecimal.ZERO;

    BigDecimal whole = BigDecimal.valueOf(x.getSecond());

    return whole.add(fractional);
}

From source file:org.jasig.portlet.calendar.adapter.ExchangeCalendarAdapterTest.java

@Test
public void testGetXmlDate() throws DatatypeConfigurationException {
    // construct a calendar representing 4:30PM on June 4, 2010
    DateTime date = new DateTime(2010, 6, 3, 16, 30, DateTimeZone.UTC);

    XMLGregorianCalendar xmlCal = adapter.getXmlDate(date);
    assertEquals(2010, xmlCal.getYear());
    assertEquals(6, xmlCal.getMonth());/*w  ww  . jav a 2 s .c  o  m*/
    assertEquals(3, xmlCal.getDay());
    assertEquals(16, xmlCal.getHour());
    assertEquals(30, xmlCal.getMinute());
    assertEquals(0, xmlCal.getSecond());
    assertEquals(0, xmlCal.getFractionalSecond().intValue());
}