Oadr20bFactory { public static String millisecondToXmlDuration(Long millisecond) { Duration newDuration = datatypeFactory.newDuration(millisecond); if (millisecond.equals(0L)) { return "PT0S"; } StringBuilder builder = new StringBuilder(); builder.append("P"); if (newDuration.getDays() > 0) { builder.append(newDuration.getDays()); builder.append("D"); } if (newDuration.getHours() > 0 || newDuration.getMinutes() > 0 || newDuration.getSeconds() > 0) { builder.append("T"); if (newDuration.getHours() > 0) { builder.append(newDuration.getHours()); builder.append("H"); } if (newDuration.getMinutes() > 0) { builder.append(newDuration.getMinutes()); builder.append("M"); } if (newDuration.getSeconds() > 0) { builder.append(newDuration.getSeconds()); builder.append("S"); } } return builder.toString(); } private  Oadr20bFactory(); static XMLGregorianCalendar timestamptoXMLCalendar(long timestamp); static Long xmlCalendarToTimestamp(XMLGregorianCalendar calendar); static Long addXMLDurationToTimestamp(Long timestamp, String duration); static Long xmlDurationToMillisecond(String duration); static String millisecondToXmlDuration(Long millisecond); static String multiplyXmlDuration(String duration, int multiplier); static OadrProfiles createOadrProfiles(); static OadrTransports createOadrTransports(); static OadrCreatedPartyRegistrationType createOadrCreatedPartyRegistrationType(EiResponseType eiresponse,
			String venId, String vtnId); static OadrDistributeEventType createOadrDistributeEventType(String vtnId, String requestId); static OadrPayload createOadrPayload(String id, Object value); static T getSignedObjectFromOadrPayload(OadrPayload payload, Class<T> klass); static Object getSignedObjectFromOadrPayload(OadrPayload payload); static OadrCreatedEventType createOadrCreatedEventType(String venId); static OadrRequestEventType createOadrRequestEventType(String venId, String requestId); static OadrResponseType createOadrResponseType(String requestId, int responseCode, String venId); static OadrCancelOptType createOadrCancelOptType(String requestId, String optId, String venId); static OadrCanceledOptType createOadrCanceledOptType(String requestId, int responseCode, String optId); static OadrCreateOptType createOadrCreateOptType(String requestId, String venId, Long createdDatetime,
			String eventId, long modificationNumber, String optId, OptTypeType optType,
			OptReasonEnumeratedType optReason); static OadrCreateOptType createOadrCreateOptType(String requestId, String venId, Long createdDatetime,
			VavailabilityType vavailabilityType, String optId, OptTypeType optType, OptReasonEnumeratedType optReason); static OadrCreatedOptType createOadrCreatedOptType(String requestId, int responseCode, String optId); static OadrCancelReportType createOadrCancelReportType(String requestId, String venId,
			boolean reportToFollow); static OadrCanceledReportType createOadrCanceledReportType(String requestId, int responseCode,
			String venId); static OadrCreateReportType createOadrCreateReportType(String requestId, String venId); static OadrCreatedReportType createOadrCreatedReportType(String requestId, int responseCode, String venId); static OadrRegisterReportType createOadrRegisterReportType(String requestId, String venId,
			String reportRequestId); static OadrRegisteredReportType createOadrRegisteredReportType(String requestId, int responseCode,
			String venId); static OadrUpdateReportType createOadrUpdateReportType(String requestId, String venId); static OadrUpdatedReportType createOadrUpdatedReportType(String requestId, int responseCode, String venId); static OadrCancelPartyRegistrationType createOadrCancelPartyRegistrationType(String requestId,
			String registrationId, String venId); static OadrCanceledPartyRegistrationType createOadrCanceledPartyRegistrationType(EiResponseType eiResponse, String registrationId, String venId); static OadrCreatePartyRegistrationType createOadrCreatePartyRegistrationType(String requestId, String venId,
			String profilName); static OadrRequestReregistrationType createOadrRequestReregistrationType(String venId); static OadrQueryRegistrationType createOadrQueryRegistrationType(String requestId); static OadrPollType createOadrPollType(String venId); static OadrProfile createOadrProfilesOadrProfile(String profileName); static OadrTransport createOadrTransportsOadrTransport(OadrTransportType transportName); static OadrPendingReportsType createOadrPendingReportsType(); static BaseUnitType createBaseUnitType(String description, String units, SiScaleCodeType siscaleCode); static CurrencyType createCurrencyType(CurrencyItemDescriptionType description,
			ISO3AlphaCurrencyCodeContentType units, SiScaleCodeType siscaleCode); static FrequencyType createFrequencyType(SiScaleCodeType siscaleCode); static ThermType createThermType(SiScaleCodeType siscaleCode); static TemperatureType createTemperatureType(TemperatureUnitType units, SiScaleCodeType siscaleCode); static PulseCountType createPulseCountType(float pulseFactor); static OadrReportRequestType createOadrReportRequestType(String reportRequestId, String reportSpecifierId,
			String granularity, String reportBackDuration); static OadrReportType createOadrUpdateReportOadrReportType(String reportId, String reportrequestId,
			String reportSpecifierId, ReportNameEnumeratedType reportName, long createdTimestamp, Long startTimestamp,
			String duration); static OadrReportType createOadrRegisterReportOadrReportType(String reportSpecifierId,
			String reportRequestId, ReportNameEnumeratedType reportName, long createdTimestamp); static OadrReportDescriptionType createOadrReportDescriptionType(); static OadrSamplingRateType createOadrSamplingRateType(); static OadrEvent createOadrDistributeEventTypeOadrEvent(); static JAXBElement<OadrDistributeEventType> createOadrDistributeEvent(OadrDistributeEventType value); static JAXBElement<OadrCreatedEventType> createOadrCreatedEvent(OadrCreatedEventType value); static JAXBElement<OadrRequestEventType> createOadrRequestEvent(OadrRequestEventType value); static JAXBElement<OadrResponseType> createOadrResponse(OadrResponseType value); static JAXBElement<OadrCancelOptType> createOadrCancelOpt(OadrCancelOptType value); static JAXBElement<OadrCanceledOptType> createOadrCanceledOpt(OadrCanceledOptType value); static JAXBElement<OadrCreateOptType> createOadrCreateOpt(OadrCreateOptType value); static JAXBElement<OadrCreatedOptType> createOadrCreatedOpt(OadrCreatedOptType value); static JAXBElement<OadrCancelReportType> createOadrCancelReport(OadrCancelReportType value); static JAXBElement<OadrCanceledReportType> createOadrCanceledReport(OadrCanceledReportType value); static JAXBElement<OadrCreateReportType> createOadrCreateReport(OadrCreateReportType value); static JAXBElement<OadrCreatedReportType> createOadrCreatedReport(OadrCreatedReportType value); static JAXBElement<OadrRegisterReportType> createOadrRegisterReport(OadrRegisterReportType value); static JAXBElement<OadrRegisteredReportType> createOadrRegisteredReport(OadrRegisteredReportType value); static JAXBElement<OadrUpdateReportType> createOadrUpdateReport(OadrUpdateReportType value); static JAXBElement<OadrUpdatedReportType> createOadrUpdatedReport(OadrUpdatedReportType value); static JAXBElement<OadrCancelPartyRegistrationType> createOadrCancelPartyRegistration(
			OadrCancelPartyRegistrationType value); static JAXBElement<OadrCanceledPartyRegistrationType> createOadrCanceledPartyRegistration(
			OadrCanceledPartyRegistrationType value); static JAXBElement<OadrCreatePartyRegistrationType> createOadrCreatePartyRegistration(
			OadrCreatePartyRegistrationType value); static JAXBElement<OadrCreatedPartyRegistrationType> createOadrCreatedPartyRegistration(
			OadrCreatedPartyRegistrationType value); static JAXBElement<OadrRequestReregistrationType> createOadrRequestReregistration(
			OadrRequestReregistrationType value); static JAXBElement<OadrQueryRegistrationType> createOadrQueryRegistration(OadrQueryRegistrationType value); static JAXBElement<OadrPollType> createOadrPoll(OadrPollType value); static JAXBElement<BaseUnitType> createCustomUnit(BaseUnitType value); static JAXBElement<CurrencyType> createCurrency(CurrencyType value); static JAXBElement<CurrencyType> createCurrencyPerKWh(CurrencyType value); static JAXBElement<CurrencyType> createCurrencyPerKW(CurrencyType value); static JAXBElement<FrequencyType> createFrequency(FrequencyType value); static JAXBElement<ThermType> createTherm(ThermType value); static JAXBElement<TemperatureType> createTemperature(TemperatureType value); static JAXBElement<PulseCountType> createPulseCount(PulseCountType value); static EventResponses createEventResponses(); static EventDescriptorType createEventDescriptorType(Long createdTimespamp, String eventId,
			Long modificationNumber, String marketContext, EventStatusEnumeratedType status); static EiResponseType createEiResponseType(String requestId, int responseCode); static EventResponse createEventResponsesEventResponse(); static QualifiedEventIDType createQualifiedEventIDType(String eventId, long modificationNumber); static IntervalType createSignalIntervalType(String intervalId, long start, String xmlDuration,
			Float value); static IntervalType createReportIntervalType(String intervalId, Long start, String xmlDuration, String rid,
			Long confidence, Float accuracy, Float value); static IntervalType createKeyTokenReportIntervalType(String intervalId, Long start, String xmlDuration,
			String rid, Long confidence, Float accuracy, PayloadKeyTokenType tokens); static IntervalType createAvobVenServiceRequestReportIntervalType(String intervalId, Long start,
			String xmlDuration, String rid, Long confidence, Float accuracy,
			PayloadAvobVenServiceRequestType requests); static IntervalType createReportIntervalType(String intervalId, Long start, String xmlDuration, String rid,
			Long confidence, Float accuracy, OadrPayloadResourceStatusType value); static CurrentValueType createCurrentValueType(float value); static PayloadFloatType createPayloadFloatType(float value); static EiEventType createEiEventType(); static EiActivePeriodType createEiActivePeriodType(); static SignalPayloadType createSignalPayloadType(float value); static EiTargetType createEiTargetType(); static JAXBElement<EiTargetType> createEiTarget(EiTargetType element); static EiEventSignalType createEiEventSignalType(); static EiEventSignalsType createEiEventSignalsType(); static ReportSpecifierType createReportSpecifierType(String reportSpecifierId, String granularity,
			String reportBackDuration); static SpecifierPayloadType createSpecifierPayloadType(JAXBElement<? extends ItemBaseType> baseItem,
			ReadingTypeEnumeratedType readingTypeEnumeratedType, String rid); static EiMarketContext createEventDescriptorTypeEiMarketContext(String marketContext); static JAXBElement<SignalPayloadType> createSignalPayload(SignalPayloadType value); static JAXBElement<PayloadFloatType> createPayloadFloat(float value); static Intervals createIntervals(); static Properties createProperties(Long start, String duration); static Tolerance createPropertiesTolerance(String startAfter); static DurationPropType createDurationPropType(String duration); static Uid createUidType(String uid); static Dtstart createDtstart(long startTimestamp); static VavailabilityType createVavailabilityType(); static AvailableType createAvailableType(long startTimestamp, String duration); static WsCalendarIntervalType createWsCalendarIntervalType(Long start, String duration); static ArrayOfVavailabilityContainedComponents createArrayOfVavailabilityContainedComponents(); static Tolerate createPropertiesToleranceTolerate(String startAfter); static ReplayProtectType createReplayProtectType(String nonce, Long timestamp); static NonceValueType createNonceValueType(String value); static JAXBElement<ReplayProtectType> createReplayProtect(ReplayProtectType value); static EndDeviceAssetType createEndDeviceAssetType(String mrid); static MeterAssetType createMeterAssetType(String mrid); static PnodeType createPnodeType(String node); static AggregatedPnodeType createAggregatedPnodeType(String node); static ServiceLocationType createServiceLocationType(String featureCollectionId, String locationId,
			Collection<? extends Double> positions); static ServiceDeliveryPointType createServiceDeliveryPointType(String node); static TransportInterfaceType createTransportInterfaceType(String pointOfReceipt, String pointOfDelivery); static VoltageType createVoltageType(SiScaleCodeType siscaleCode); static EnergyApparentType createEnergyApparentType(SiScaleCodeType siscaleCode); static EnergyReactiveType createEnergyReactiveType(SiScaleCodeType siscaleCode); static EnergyRealType createEnergyRealType(SiScaleCodeType siscaleCode); static PowerApparentType createPowerApparentType(SiScaleCodeType siscaleCode, BigDecimal hertz,
			BigDecimal voltage, boolean isAC); static PowerReactiveType createPowerReactiveType(SiScaleCodeType siscaleCode, BigDecimal hertz,
			BigDecimal voltage, boolean isAC); static PowerRealType createPowerRealType(PowerRealUnitType unit, SiScaleCodeType siscaleCode,
			BigDecimal hertz, BigDecimal voltage, boolean isAC); static PowerAttributesType createPowerAttributesType(BigDecimal hertz, BigDecimal voltage, boolean isAC); static JAXBElement<VoltageType> createVoltage(VoltageType value); static JAXBElement<EnergyApparentType> createEnergyApparent(EnergyApparentType value); static JAXBElement<EnergyReactiveType> createEnergyReactive(EnergyReactiveType value); static JAXBElement<EnergyRealType> createEnergyReal(EnergyRealType value); static JAXBElement<PowerApparentType> createPowerApparent(PowerApparentType value); static JAXBElement<PowerReactiveType> createPowerReactive(PowerReactiveType value); static JAXBElement<PowerRealType> createPowerReal(PowerRealType value); static ServiceAreaType createServiceAreaType(String featureCollectionId, String locationId,
			Collection<? extends Double> gmlPosition); static FeatureCollection createFeatureCollection(String featureCollectionId, String locationId,
			Collection<? extends Double> positions); static Location createFeatureCollectionLocation(String id, Collection<? extends Double> positions); static Polygon createFeatureCollectionLocationPolygon(String id, Collection<? extends Double> positions); static Exterior createFeatureCollectionLocationPolygonExterior(Collection<? extends Double> positions); static LinearRing createFeatureCollectionLocationPolygonExteriorLinearRing(
			Collection<? extends Double> positions); static JAXBElement<OadrReportDescriptionType> createOadrReportDescription(OadrReportDescriptionType value); static OadrReportPayloadType createReportPayloadType(String rid, Long confidence, Float accuracy,
			Float value); static OadrReportPayloadType createReportPayloadType(String rid, Long confidence, Float accuracy,
			OadrPayloadResourceStatusType value); static OadrReportPayloadType createReportPayloadType(String rid, Long confidence, Float accuracy,
			PayloadKeyTokenType tokens); static OadrReportPayloadType createReportPayloadType(String rid, Long confidence, Float accuracy,
			PayloadAvobVenServiceRequestType requests); static JAXBElement<OadrReportPayloadType> createOadrReportPayload(OadrReportPayloadType value); static OadrPayloadResourceStatusType createOadrPayloadResourceStatusType(
			OadrLoadControlStateType loadControlState, boolean manualOverride, boolean online); static JAXBElement<OadrPayloadResourceStatusType> createOadrPayloadResourceStatus(
			OadrPayloadResourceStatusType value); static OadrLoadControlStateType createOadrLoadControlStateType(OadrLoadControlStateTypeType capacity,
			OadrLoadControlStateTypeType levelOffset, OadrLoadControlStateTypeType percentOffset,
			OadrLoadControlStateTypeType setPoint); static OadrLoadControlStateTypeType createOadrLoadControlStateTypeType(float current, Float normal,
			Float min, Float max); static PayloadKeyTokenType createPayloadKeyTokenType(List<KeyTokenType> tokens); static JAXBElement<PayloadKeyTokenType> createPayloadKeyToken(PayloadKeyTokenType value); static JAXBElement<PayloadAvobVenServiceRequestType> createPayloadAvobVenServiceRequest(
			PayloadAvobVenServiceRequestType value);  }
@Test public void millisecondToXmlDurationTest() { String duration = null; duration = Oadr20bFactory.millisecondToXmlDuration(0L); assertNotNull(duration); assertEquals("PT0S", duration); duration = Oadr20bFactory.millisecondToXmlDuration(1000L); assertNotNull(duration); assertEquals("PT1S", duration); Long dur = 25 * 60 * 60 * 1000L + 60 * 1000L + 1000L; duration = Oadr20bFactory.millisecondToXmlDuration(dur); assertNotNull(duration); assertEquals("P1DT1H1M1S", duration); boolean ex = false; try { duration = Oadr20bFactory.millisecondToXmlDuration(null); } catch (Exception e) { ex = true; } assertTrue(ex); }