Example usage for java.time OffsetDateTime toString

List of usage examples for java.time OffsetDateTime toString

Introduction

In this page you can find the example usage for java.time OffsetDateTime toString.

Prototype

@Override
public String toString() 

Source Link

Document

Outputs this date-time as a String , such as 2007-12-03T10:15:30+01:00 .

Usage

From source file:Main.java

public static void main(String[] args) {
    OffsetDateTime o = OffsetDateTime.MAX;

    System.out.println(o.toString());
}

From source file:com.intuit.wasabi.api.pagination.filters.FilterUtil.java

/**
 * Formats a date as it is shown in the UI to allow for matching searches on date fields.
 * Needs the requesting user's timezone offset to UTC for correct matches.
 *
 * @param date           the date/* w  w w  .j ava  2 s  .  c  o m*/
 * @param timeZoneOffset the timezone offset to UTC
 * @return a timezone offset adjusted string of the UI pattern {@code MMM d, YYYY HH:mm:ss a}.
 */
/*test*/
static String formatDateTimeAsUI(OffsetDateTime date, String timeZoneOffset) {
    try {
        return date.format(DateTimeFormatter.ofPattern("MMM d, YYYY HH:mm:ss a")
                .withZone(ZoneId.ofOffset("UTC", ZoneOffset.of(timeZoneOffset))));
    } catch (DateTimeException dateTimeException) {
        throw new PaginationException(ErrorCode.FILTER_KEY_UNPROCESSABLE,
                "Wrong format: Can not parse timezone '" + timeZoneOffset + "' or date " + date.toString()
                        + " properly.",
                dateTimeException);
    }
}

From source file:io.smalldata.ohmageomh.data.converter.OffsetDateTimeToStringConverter.java

@Override
public String convert(OffsetDateTime source) {

    if (source == null) {
        return null;
    }/*from w  w  w . j av a2 s .c o  m*/

    return source.toString();
}

From source file:de.kaiserpfalzEdv.office.core.security.impl.SecurityTicket.java

public boolean isValid() {
    OffsetDateTime now = OffsetDateTime.now(TIMEZONE);

    System.out.println(validity.toString() + " is hopefully after " + now.toString());

    return validity.isAfter(now);
}

From source file:org.jimsey.projects.turbine.fuel.domain.TickJson.java

public TickJson(OffsetDateTime date, double open, double high, double low, double close, double volume,
        String symbol, String market, String timestamp) {
    super(DateTime.parse(date.toString(), ISODateTimeFormat.dateTimeParser()), open, high, low, close, volume);
    this.timestamp = date;
    this.symbol = symbol;
    this.market = market;
    try {//from  w  w  w.ja  v a2 s .c  o m
        this.date = date.toInstant().toEpochMilli();
    } catch (Exception e) {
        logger.warn("Could not parse date: {}", date.toString());
    }
    try {
        this.timestamp = OffsetDateTime.parse(timestamp);
    } catch (Exception e) {
        logger.warn("Could not parse timestamp: {}", timestamp);
    }
}

From source file:ddf.catalog.registry.federationadmin.service.impl.FederationAdminServiceImpl.java

private void createIdentityNode() throws SourceUnavailableException, IngestException {

    String registryPackageId = UUID.randomUUID().toString().replaceAll("-", "");
    RegistryPackageType registryPackage = RIM_FACTORY.createRegistryPackageType();
    registryPackage.setId(registryPackageId);
    registryPackage.setObjectType(RegistryConstants.REGISTRY_NODE_OBJECT_TYPE);

    ExtrinsicObjectType extrinsicObject = RIM_FACTORY.createExtrinsicObjectType();
    extrinsicObject.setObjectType(RegistryConstants.REGISTRY_NODE_OBJECT_TYPE);

    String extrinsicObjectId = UUID.randomUUID().toString().replaceAll("-", "");
    extrinsicObject.setId(extrinsicObjectId);

    String siteName = SystemInfo.getSiteName();
    if (StringUtils.isNotBlank(siteName)) {
        extrinsicObject.setName(getInternationalStringTypeFromString(siteName));
    }/*from w  ww .j a  v  a2s.  c  o m*/

    String home = SystemBaseUrl.getBaseUrl();
    if (StringUtils.isNotBlank(home)) {
        extrinsicObject.setHome(home);
    }

    String version = SystemInfo.getVersion();
    if (StringUtils.isNotBlank(version)) {
        VersionInfoType versionInfo = RIM_FACTORY.createVersionInfoType();
        versionInfo.setVersionName(version);

        extrinsicObject.setVersionInfo(versionInfo);
    }

    OffsetDateTime now = OffsetDateTime.now(ZoneId.of(ZoneOffset.UTC.toString()));
    String rightNow = now.toString();
    ValueListType valueList = RIM_FACTORY.createValueListType();
    valueList.getValue().add(rightNow);

    SlotType1 lastUpdated = RIM_FACTORY.createSlotType1();
    lastUpdated.setValueList(RIM_FACTORY.createValueList(valueList));
    lastUpdated.setSlotType(DatatypeConstants.DATETIME.toString());
    lastUpdated.setName(RegistryConstants.XML_LAST_UPDATED_NAME);
    extrinsicObject.getSlot().add(lastUpdated);

    SlotType1 liveDate = RIM_FACTORY.createSlotType1();
    liveDate.setValueList(RIM_FACTORY.createValueList(valueList));
    liveDate.setSlotType(DatatypeConstants.DATETIME.toString());
    liveDate.setName(RegistryConstants.XML_LIVE_DATE_NAME);
    extrinsicObject.getSlot().add(liveDate);

    if (registryPackage.getRegistryObjectList() == null) {
        registryPackage.setRegistryObjectList(RIM_FACTORY.createRegistryObjectListType());
    }

    registryPackage.getRegistryObjectList().getIdentifiable()
            .add(RIM_FACTORY.createIdentifiable(extrinsicObject));

    Metacard identityMetacard = jaxbToMetacard(registryPackage);
    if (identityMetacard != null) {
        Attribute registryNodeAttribute = new AttributeImpl(RegistryObjectMetacardType.REGISTRY_IDENTITY_NODE,
                true);
        identityMetacard.setAttribute(registryNodeAttribute);

        addLocalEntry(identityMetacard);
    }
}

From source file:org.jimsey.projects.turbine.fuel.domain.Entity.java

public Entity(OffsetDateTime date, double close, String symbol, String market, String name, String timestamp) {
    this.timestamp = date;
    this.close = close;
    this.symbol = symbol;
    this.market = market;
    this.name = name;
    try {//  w w  w .  j  a  v  a2  s .co m
        this.date = date.toInstant().toEpochMilli();
    } catch (Exception e) {
        logger.warn("Could not parse date: {}", date.toString());
    }
    try {
        this.timestamp = OffsetDateTime.parse(timestamp);
    } catch (Exception e) {
        logger.warn("Could not parse timestamp: {}", timestamp);
    }

}

From source file:org.codice.ddf.registry.federationadmin.impl.FederationAdmin.java

private void updateDateFields(RegistryPackageType rpt) {

    ExtrinsicObjectType nodeInfo = null;
    for (JAXBElement identifiable : rpt.getRegistryObjectList().getIdentifiable()) {
        RegistryObjectType registryObject = (RegistryObjectType) identifiable.getValue();

        if (registryObject instanceof ExtrinsicObjectType
                && RegistryConstants.REGISTRY_NODE_OBJECT_TYPE.equals(registryObject.getObjectType())) {
            nodeInfo = (ExtrinsicObjectType) registryObject;
            break;
        }//from   w ww .java 2 s. c om
    }
    if (nodeInfo != null) {
        boolean liveDateFound = false;
        boolean lastUpdatedFound = false;

        OffsetDateTime now = OffsetDateTime.now(ZoneId.of(ZoneOffset.UTC.toString()));
        String rightNow = now.toString();

        for (SlotType1 slot : nodeInfo.getSlot()) {
            if (slot.getName().equals(RegistryConstants.XML_LIVE_DATE_NAME)) {
                liveDateFound = true;
            } else if (slot.getName().equals(RegistryConstants.XML_LAST_UPDATED_NAME)) {
                ValueListType valueList = EbrimConstants.RIM_FACTORY.createValueListType();
                valueList.getValue().add(rightNow);
                slot.setValueList(EbrimConstants.RIM_FACTORY.createValueList(valueList));
                lastUpdatedFound = true;
            }
        }

        if (!liveDateFound) {
            SlotType1 liveDate = slotHelper.create(RegistryConstants.XML_LIVE_DATE_NAME, rightNow, DATE_TIME);

            nodeInfo.getSlot().add(liveDate);
        }

        if (!lastUpdatedFound) {
            SlotType1 lastUpdated = slotHelper.create(RegistryConstants.XML_LAST_UPDATED_NAME, rightNow,
                    DATE_TIME);

            nodeInfo.getSlot().add(lastUpdated);
        }
    }
}

From source file:org.codice.ddf.registry.federationadmin.service.impl.IdentityNodeInitialization.java

private void createIdentityNode() throws FederationAdminException {
    String registryPackageId = System.getProperty(RegistryConstants.REGISTRY_ID_PROPERTY);
    if (StringUtils.isEmpty(registryPackageId)) {
        registryPackageId = RegistryConstants.GUID_PREFIX + UUID.randomUUID().toString().replaceAll("-", "");
        setSystemRegistryId(registryPackageId);
    }/*from   ww w. j  ava2 s . c  om*/
    LOGGER.info("Creating registry identity node: {} {}", SystemInfo.getSiteName(), registryPackageId);
    RegistryPackageType registryPackage = RIM_FACTORY.createRegistryPackageType();
    registryPackage.setId(registryPackageId);
    registryPackage.setObjectType(RegistryConstants.REGISTRY_NODE_OBJECT_TYPE);

    ExtrinsicObjectType extrinsicObject = RIM_FACTORY.createExtrinsicObjectType();
    extrinsicObject.setObjectType(RegistryConstants.REGISTRY_NODE_OBJECT_TYPE);

    String extrinsicObjectId = RegistryConstants.GUID_PREFIX + UUID.randomUUID().toString().replaceAll("-", "");
    extrinsicObject.setId(extrinsicObjectId);

    String siteName = SystemInfo.getSiteName();
    if (StringUtils.isNotBlank(siteName)) {
        extrinsicObject.setName(internationalStringTypeHelper.create(siteName));
    } else {
        extrinsicObject.setName(internationalStringTypeHelper.create(UNKNOWN_SITE_NAME));
    }

    String home = SystemBaseUrl.EXTERNAL.getBaseUrl();
    extrinsicObject.setHome(home);

    String version = SystemInfo.getVersion();
    if (StringUtils.isNotBlank(version)) {
        VersionInfoType versionInfo = RIM_FACTORY.createVersionInfoType();
        versionInfo.setVersionName(version);

        extrinsicObject.setVersionInfo(versionInfo);
    }

    OffsetDateTime now = OffsetDateTime.now(ZoneId.of(ZoneOffset.UTC.toString()));
    String rightNow = now.toString();

    SlotType1 lastUpdated = slotTypeHelper.create(RegistryConstants.XML_LAST_UPDATED_NAME, rightNow, DATE_TIME);
    extrinsicObject.getSlot().add(lastUpdated);

    SlotType1 liveDate = slotTypeHelper.create(RegistryConstants.XML_LIVE_DATE_NAME, rightNow, DATE_TIME);
    extrinsicObject.getSlot().add(liveDate);

    if (registryPackage.getRegistryObjectList() == null) {
        registryPackage.setRegistryObjectList(RIM_FACTORY.createRegistryObjectListType());
    }

    registryPackage.getRegistryObjectList().getIdentifiable()
            .add(RIM_FACTORY.createIdentifiable(extrinsicObject));

    Metacard identityMetacard = getRegistryMetacardFromRegistryPackage(registryPackage);
    if (identityMetacard != null) {
        identityMetacard
                .setAttribute(new AttributeImpl(RegistryObjectMetacardType.REGISTRY_IDENTITY_NODE, true));
        identityMetacard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REGISTRY_LOCAL_NODE, true));
        federationAdminService.addRegistryEntry(identityMetacard);
    }
}

From source file:org.jbpm.bpmn2.IntermediateEventTest.java

@Test(timeout = 10000)
public void testTimerBoundaryEventDateISO() throws Exception {
    NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener(
            "TimerEvent", 1);

    KieBase kbase = createKnowledgeBaseWithoutDumper("BPMN2-TimerBoundaryEventDateISO.bpmn2");
    ksession = createKnowledgeSession(kbase);
    ksession.addEventListener(countDownListener);
    ksession.getWorkItemManager().registerWorkItemHandler("MyTask", new DoNothingWorkItemHandler());
    HashMap<String, Object> params = new HashMap<String, Object>();
    OffsetDateTime plusTwoSeconds = OffsetDateTime.now().plusSeconds(2);
    params.put("date", plusTwoSeconds.toString());
    ProcessInstance processInstance = ksession.startProcess("TimerBoundaryEvent", params);
    assertProcessInstanceActive(processInstance);
    countDownListener.waitTillCompleted();
    ksession = restoreSession(ksession, true);
    assertProcessInstanceFinished(processInstance, ksession);

}