Example usage for java.time Instant now

List of usage examples for java.time Instant now

Introduction

In this page you can find the example usage for java.time Instant now.

Prototype

public static Instant now() 

Source Link

Document

Obtains the current instant from the system clock.

Usage

From source file:com.vmware.photon.controller.api.client.resource.VmApiTest.java

@Test
public void testPerformStopOperationAsync() throws IOException, InterruptedException {
    final Task responseTask = new Task();
    responseTask.setId("12345");
    responseTask.setState("QUEUED");
    responseTask.setQueuedTime(Date.from(Instant.now()));

    ObjectMapper mapper = new ObjectMapper();
    String serializedTask = mapper.writeValueAsString(responseTask);

    setupMocks(serializedTask, HttpStatus.SC_CREATED);

    VmApi vmApi = new VmApi(restClient);

    final CountDownLatch latch = new CountDownLatch(1);

    vmApi.performStopOperationAsync("foo", new FutureCallback<Task>() {
        @Override//from w w w .  ja  v  a 2  s.co  m
        public void onSuccess(@Nullable Task result) {
            assertEquals(result, responseTask);
            latch.countDown();
        }

        @Override
        public void onFailure(Throwable t) {
            fail(t.toString());
            latch.countDown();
        }
    });

    assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true));
}

From source file:org.noorganization.instalist.server.api.IngredientResourceTest.java

@Test
public void testPutIngredient() throws Exception {
    String url = "/groups/%d/ingredients/%s";
    Instant preUpdate = mIngredient.getUpdated();
    IngredientInfo updatedIngred = new IngredientInfo().withAmount(3f);

    Response notAuthorizedResponse = target(
            String.format(url, mGroup.getId(), mIngredient.getUUID().toString())).request()
                    .put(Entity.json(updatedIngred));
    assertEquals(401, notAuthorizedResponse.getStatus());

    Response wrongAuthResponse = target(String.format(url, mGroup.getId(), mIngredient.getUUID().toString()))
            .request().header(HttpHeaders.AUTHORIZATION, "X-Token wrongauth").put(Entity.json(updatedIngred));
    assertEquals(401, wrongAuthResponse.getStatus());

    Response wrongGroupResponse = target(
            String.format(url, mNAGroup.getId(), mNAIngredient.getUUID().toString())).request()
                    .header(HttpHeaders.AUTHORIZATION, "X-Token " + mToken).put(Entity.json(updatedIngred));
    assertEquals(401, wrongGroupResponse.getStatus());

    Response wrongListResponse = target(String.format(url, mGroup.getId(), mNAIngredient.getUUID().toString()))
            .request().header(HttpHeaders.AUTHORIZATION, "X-Token " + mToken).put(Entity.json(updatedIngred));
    assertEquals(404, wrongListResponse.getStatus());

    Response goneResponse = target(String.format(url, mGroup.getId(), mDeletedIngredient.getUUID().toString()))
            .request().header(HttpHeaders.AUTHORIZATION, "X-Token " + mToken).put(Entity.json(updatedIngred));
    assertEquals(410, goneResponse.getStatus());
    mManager.refresh(mIngredient);/* w  w  w.ja v a  2  s .c om*/
    assertEquals(1f, mIngredient.getAmount(), 0.001f);

    updatedIngred.setLastChanged(new Date(preUpdate.toEpochMilli() - 10000));
    Response conflictResponse = target(String.format(url, mGroup.getId(), mIngredient.getUUID().toString()))
            .request().header(HttpHeaders.AUTHORIZATION, "X-Token " + mToken).put(Entity.json(updatedIngred));
    assertEquals(409, conflictResponse.getStatus());
    mManager.refresh(mIngredient);
    assertEquals(1f, mIngredient.getAmount(), 0.001f);

    updatedIngred.setLastChanged(Date.from(Instant.now()));
    Response okResponse = target(String.format(url, mGroup.getId(), mIngredient.getUUID().toString())).request()
            .header(HttpHeaders.AUTHORIZATION, "X-Token " + mToken).put(Entity.json(updatedIngred));
    assertEquals(200, okResponse.getStatus());
    mManager.refresh(mIngredient);
    assertEquals(3f, mIngredient.getAmount(), 0.001f);
    assertTrue(preUpdate + " is not before " + mIngredient.getUpdated(),
            preUpdate.isBefore(mIngredient.getUpdated()));
}

From source file:com.vmware.photon.controller.api.client.resource.VmRestApiTest.java

@Test
public void testPerformStopOperationAsync() throws IOException, InterruptedException {
    final Task responseTask = new Task();
    responseTask.setId("12345");
    responseTask.setState("QUEUED");
    responseTask.setQueuedTime(Date.from(Instant.now()));

    ObjectMapper mapper = new ObjectMapper();
    String serializedTask = mapper.writeValueAsString(responseTask);

    setupMocks(serializedTask, HttpStatus.SC_CREATED);

    VmApi vmApi = new VmRestApi(restClient);

    final CountDownLatch latch = new CountDownLatch(1);

    vmApi.performStopOperationAsync("foo", new FutureCallback<Task>() {
        @Override/*from  w w w  . jav  a2 s . co  m*/
        public void onSuccess(@Nullable Task result) {
            assertEquals(result, responseTask);
            latch.countDown();
        }

        @Override
        public void onFailure(Throwable t) {
            fail(t.toString());
            latch.countDown();
        }
    });

    assertThat(latch.await(COUNTDOWNLATCH_AWAIT_TIMEOUT, TimeUnit.SECONDS), is(true));
}

From source file:ch.unibas.charmmtools.gui.step1.mdAssistant.CHARMM_GUI_InputAssistant.java

/**
 * Try to generate an input file with standard parameters, it can be edited later
 *///w w  w.  j a va2  s.co  m
@FXML
protected void GenerateInputFile() {

    //        try {
    String folderPath = this.work_directory.getAbsolutePath();

    // get filenames
    //        String corname_gas = ResourceUtils.getRelativePath(textfield_COR_gas.getText(), folderPath);
    //        String corname_liquid = ResourceUtils.getRelativePath(textfield_COR_liquid.getText(), folderPath);
    //        String rtfname = ResourceUtils.getRelativePath(textfield_RTF.getText(), folderPath);
    //        String parname = ResourceUtils.getRelativePath(textfield_PAR.getText(), folderPath);
    //        String lpunname = ResourceUtils.getRelativePath(textfield_LPUN.getText(), folderPath);
    String corname_gas = textfield_COR_gas.getText();
    String corname_liquid = textfield_COR_liquid.getText();
    String rtfname = textfield_RTF.getText();
    String parname = textfield_PAR.getText();
    String lpunname = textfield_LPUN.getText();
    String time = Long.toString(Instant.now().getEpochSecond());

    File gas_vdw_dir = new File(folderPath + "/gas_" + time + "/vdw");
    File gas_mtp_dir = new File(folderPath + "/gas_" + time + "/mtp");
    File solv_vdw_dir = new File(folderPath + "/solv_" + time + "/vdw");
    File solv_mtp_dir = new File(folderPath + "/solv_" + time + "/mtp");

    gas_vdw_dir.mkdirs();
    gas_mtp_dir.mkdirs();
    solv_vdw_dir.mkdirs();
    solv_mtp_dir.mkdirs();
    //        } catch (IOException ex) {
    //            logger.error(ex);
    //        }

    File gasFile = null;
    CHARMM_Input gasInp = null;
    try {
        gasFile = new File(gas_vdw_dir.getParent(), "gas_phase.inp");
        gasInp = new CHARMM_Input_GasPhase(corname_gas, rtfname, parname, lpunname, gasFile);
        tab_list.add(new MyTab("?/H Gas Phase",
                new String(Files.readAllBytes(Paths.get(gasFile.getAbsolutePath())))));
        inp.add(gasInp);
    } catch (IOException ex) {
        logger.error("Error while generating " + gasFile.getAbsolutePath() + " : " + ex);
    }

    File liqFile = null;
    CHARMM_Input liqInp = null;
    try {
        liqFile = new File(solv_vdw_dir.getParent(), "pure_liquid.inp");
        liqInp = new CHARMM_Input_PureLiquid(corname_liquid, rtfname, parname, lpunname, liqFile);
        tab_list.add(new MyTab("?/H Pure Liquid",
                new String(Files.readAllBytes(Paths.get(liqFile.getAbsolutePath())))));
        inp.add(liqInp);
    } catch (IOException ex) {
        logger.error("Error while generating " + liqFile.getAbsolutePath() + " : " + ex);
    }

    //            RedLabel_Notice.setVisible(true);
    String corname_solv = textfield_COR_solv.getText();
    double lamb_spacing_val = Double.valueOf(lambda_space.getText());

    in_gas_vdw = new CHARMM_Generator_DGHydr(corname_gas, rtfname, parname, lpunname, "vdw", 0.0,
            lamb_spacing_val, 1.0, gas_vdw_dir);
    //            CHARMM_inFile.addAll(in_gas_vdw.getMyFiles());
    //
    in_gas_mtp = new CHARMM_Generator_DGHydr(corname_gas, rtfname, parname, lpunname, "mtp", 0.0,
            lamb_spacing_val, 1.0, gas_mtp_dir);
    //            CHARMM_inFile.addAll(in_gas_mtp.getMyFiles());
    //
    in_solv_vdw = new CHARMM_Generator_DGHydr(corname_gas, corname_solv, rtfname, rtfname, parname, lpunname,
            "vdw", 0.0, lamb_spacing_val, 1.0, solv_vdw_dir);
    //            CHARMM_inFile.addAll(in_solv_vdw.getMyFiles());
    //
    in_solv_mtp = new CHARMM_Generator_DGHydr(corname_gas, corname_solv, rtfname, rtfname, parname, lpunname,
            "mtp", 0.0, lamb_spacing_val, 1.0, solv_mtp_dir);

    try {
        for (File fi : in_gas_vdw.getMyFiles()) {
            tab_list.add(
                    new MyTab("Gas & VDW", new String(Files.readAllBytes(Paths.get(fi.getAbsolutePath())))));
        }

        for (File fi : in_gas_mtp.getMyFiles()) {
            tab_list.add(
                    new MyTab("Gas & MTP", new String(Files.readAllBytes(Paths.get(fi.getAbsolutePath())))));
        }

        for (File fi : in_solv_vdw.getMyFiles()) {
            tab_list.add(
                    new MyTab("Solv & VDW", new String(Files.readAllBytes(Paths.get(fi.getAbsolutePath())))));
        }

        for (File fi : in_solv_mtp.getMyFiles()) {
            tab_list.add(
                    new MyTab("Solv & MTP", new String(Files.readAllBytes(Paths.get(fi.getAbsolutePath())))));
        }
    } catch (IOException ex) {
        logger.error("Error while generating DG files : " + ex);
    }

    tab_pane.getTabs().addAll(tab_list);

    button_run_CHARMM.setDisable(false);

    /**
     * If success enable button for saving
     */
    //        button_save_to_file.setDisable(false);
}

From source file:org.noorganization.instalist.server.api.TaggedProductResourceTest.java

@Test
public void testPutTaggedProduct() throws Exception {
    String url = "/groups/%d/taggedproducts/%s";
    Instant preUpdate = mTaggedProduct.getUpdated();
    TaggedProductInfo updatedTP = new TaggedProductInfo().withTagUUID(mNATag.getUUID());

    Response notAuthorizedResponse = target(
            String.format(url, mGroup.getId(), mTaggedProduct.getUUID().toString())).request()
                    .put(Entity.json(updatedTP));
    assertEquals(401, notAuthorizedResponse.getStatus());

    Response wrongAuthResponse = target(String.format(url, mGroup.getId(), mTaggedProduct.getUUID().toString()))
            .request().header(HttpHeaders.AUTHORIZATION, "X-Token wrongauth").put(Entity.json(updatedTP));
    assertEquals(401, wrongAuthResponse.getStatus());

    Response wrongGroupResponse = target(
            String.format(url, mNAGroup.getId(), mNATaggedProduct.getUUID().toString())).request()
                    .header(HttpHeaders.AUTHORIZATION, "X-Token " + mToken).put(Entity.json(updatedTP));
    assertEquals(401, wrongGroupResponse.getStatus());

    Response wrongListResponse = target(
            String.format(url, mGroup.getId(), mNATaggedProduct.getUUID().toString())).request()
                    .header(HttpHeaders.AUTHORIZATION, "X-Token " + mToken).put(Entity.json(updatedTP));
    assertEquals(404, wrongListResponse.getStatus());

    Response goneResponse = target(String.format(url, mGroup.getId(), mDeletedIngredient.getUUID().toString()))
            .request().header(HttpHeaders.AUTHORIZATION, "X-Token " + mToken).put(Entity.json(updatedTP));
    assertEquals(410, goneResponse.getStatus());

    Response wrongRefResponse = target(String.format(url, mGroup.getId(), mTaggedProduct.getUUID().toString()))
            .request().header(HttpHeaders.AUTHORIZATION, "X-Token " + mToken).put(Entity.json(updatedTP));
    assertEquals(400, wrongRefResponse.getStatus());
    mManager.refresh(mTaggedProduct);//ww w  . j ava 2s .  co m
    assertEquals(mTag.getUUID(), mTaggedProduct.getTag().getUUID());

    updatedTP.setTagUUID(mTag.getUUID());
    updatedTP.setLastChanged(new Date(preUpdate.toEpochMilli() - 10000));
    Response conflictResponse = target(String.format(url, mGroup.getId(), mTaggedProduct.getUUID().toString()))
            .request().header(HttpHeaders.AUTHORIZATION, "X-Token " + mToken).put(Entity.json(updatedTP));
    assertEquals(409, conflictResponse.getStatus());
    mManager.refresh(mTaggedProduct);
    assertEquals(mTag.getUUID(), mTaggedProduct.getTag().getUUID());

    updatedTP.setLastChanged(Date.from(Instant.now()));
    Response okResponse = target(String.format(url, mGroup.getId(), mTaggedProduct.getUUID().toString()))
            .request().header(HttpHeaders.AUTHORIZATION, "X-Token " + mToken).put(Entity.json(updatedTP));
    assertEquals(200, okResponse.getStatus());
    mManager.refresh(mTaggedProduct);
    assertTrue(preUpdate + " is not before " + mTaggedProduct.getUpdated(),
            preUpdate.isBefore(mTaggedProduct.getUpdated()));
}

From source file:org.noorganization.instalist.server.api.ProductResourceTest.java

@Test
public void testPutProduct() throws Exception {
    String url = "/groups/%d/products/%s";
    Instant preUpdate = mProduct.getUpdated();
    ProductInfo updatedProduct = new ProductInfo().withDeleted(false).withName("changedproduct");

    Response notAuthorizedResponse = target(String.format(url, mGroup.getId(), mProduct.getUUID().toString()))
            .request().put(Entity.json(updatedProduct));
    assertEquals(401, notAuthorizedResponse.getStatus());

    Response wrongAuthResponse = target(String.format(url, mGroup.getId(), mProduct.getUUID().toString()))
            .request().header(HttpHeaders.AUTHORIZATION, "X-Token wrongauth").put(Entity.json(updatedProduct));
    assertEquals(401, wrongAuthResponse.getStatus());

    Response wrongGroupResponse = target(String.format(url, mNAGroup.getId(), mNAProduct.getUUID().toString()))
            .request().header(HttpHeaders.AUTHORIZATION, "X-Token " + mToken).put(Entity.json(updatedProduct));
    assertEquals(401, wrongGroupResponse.getStatus());

    Response wrongListResponse = target(String.format(url, mGroup.getId(), mNAProduct.getUUID().toString()))
            .request().header(HttpHeaders.AUTHORIZATION, "X-Token " + mToken).put(Entity.json(updatedProduct));
    assertEquals(404, wrongListResponse.getStatus());

    Response goneResponse = target(String.format(url, mGroup.getId(), mDeletedProduct.getUUID().toString()))
            .request().header(HttpHeaders.AUTHORIZATION, "X-Token " + mToken).put(Entity.json(updatedProduct));
    assertEquals(410, goneResponse.getStatus());
    mManager.refresh(mProduct);//from w  ww  .j  a  va2  s  . co m
    assertEquals("product1", mProduct.getName());

    updatedProduct.setLastChanged(new Date(preUpdate.toEpochMilli() - 10000));
    Response conflictResponse = target(String.format(url, mGroup.getId(), mProduct.getUUID().toString()))
            .request().header(HttpHeaders.AUTHORIZATION, "X-Token " + mToken).put(Entity.json(updatedProduct));
    assertEquals(409, conflictResponse.getStatus());
    mManager.refresh(mProduct);
    assertEquals("product1", mProduct.getName());

    updatedProduct.setLastChanged(Date.from(Instant.now()));
    Response okResponse = target(String.format(url, mGroup.getId(), mProduct.getUUID().toString())).request()
            .header(HttpHeaders.AUTHORIZATION, "X-Token " + mToken).put(Entity.json(updatedProduct));
    assertEquals(200, okResponse.getStatus());
    mManager.refresh(mProduct);
    assertEquals("changedproduct", mProduct.getName());
    assertEquals(1f, mProduct.getDefaultAmount(), 0.001f);
    assertEquals(0.5f, mProduct.getStepAmount(), 0.001f);
    assertNull(mProduct.getUnit());
    assertTrue(preUpdate + " is not before " + mProduct.getUpdated(),
            preUpdate.isBefore(mProduct.getUpdated()));
}

From source file:com.vmware.admiral.compute.container.HostContainerListDataCollection.java

@Override
public void handlePatch(Operation op) {
    ContainerListCallback body = op.getBody(ContainerListCallback.class);

    if (body.hostAdapterReference == null) {
        body.hostAdapterReference = ContainerHostDataCollectionService.getDefaultHostAdapter(getHost());
    }/*ww w .  java  2 s. c om*/

    String containerHostLink = body.containerHostLink;
    if (containerHostLink == null) {
        logWarning("'containerHostLink' is required");
        op.complete();
        return;
    }

    HostContainerListDataCollectionState state = getState(op);
    if (body.unlockDataCollectionForHost) {
        // patch to mark that there is no active list containers data collection for a given
        // host.
        state.containerHostLinks.remove(containerHostLink);
        op.complete();
        return;
    }

    AssertUtil.assertNotNull(body.containerIdsAndNames, "containerIdsAndNames");

    if (Logger.getLogger(this.getClass().getName()).isLoggable(Level.FINE)) {
        logFine("Host container list callback invoked for host [%s] with container IDs: %s", containerHostLink,
                body.containerIdsAndNames.keySet().stream().collect(Collectors.toList()));
    }

    // the patch will succeed regardless of the synchronization process
    if (state.containerHostLinks.get(containerHostLink) != null && Instant.now()
            .isBefore(Instant.ofEpochMilli((state.containerHostLinks.get(containerHostLink))))) {
        if (Logger.getLogger(this.getClass().getName()).isLoggable(Level.FINE)) {
            logFine("Host container list callback for host [%s] with container IDs: %s "
                    + "skipped, another instance is active", containerHostLink,
                    body.containerIdsAndNames.keySet().stream().collect(Collectors.toList()));
        }
        op.complete();
        return; // return since there is an active data collection for this host.
    } else {
        state.containerHostLinks.put(containerHostLink,
                Instant.now().toEpochMilli() + DATA_COLLECTION_LOCK_TIMEOUT_MILLISECONDS);
        op.complete();
        // continue with the data collection.
    }

    List<ContainerState> containerStates = new ArrayList<ContainerState>();
    QueryTask queryTask = QueryUtil.buildPropertyQuery(ContainerState.class,
            ContainerState.FIELD_NAME_PARENT_LINK, containerHostLink);
    QueryUtil.addExpandOption(queryTask);

    QueryUtil.addBroadcastOption(queryTask);
    new ServiceDocumentQuery<ContainerState>(getHost(), ContainerState.class).query(queryTask, (r) -> {
        if (r.hasException()) {
            logSevere("Failed to query for existing ContainerState instances: %s",
                    r.getException() instanceof CancellationException ? r.getException().getMessage()
                            : Utils.toString(r.getException()));
            unlockCurrentDataCollectionForHost(containerHostLink);
        } else if (r.hasResult()) {
            containerStates.add(r.getResult());
        } else {
            AdapterRequest request = new AdapterRequest();
            request.operationTypeId = ContainerHostOperationType.LIST_CONTAINERS.id;
            request.serviceTaskCallback = ServiceTaskCallback.createEmpty();
            request.resourceReference = UriUtils.buildUri(getHost(), containerHostLink);
            sendRequest(Operation.createPatch(body.hostAdapterReference).setBody(request)
                    .addPragmaDirective(Operation.PRAGMA_DIRECTIVE_QUEUE_FOR_SERVICE_AVAILABILITY)
                    .setCompletion((o, ex) -> {
                        if (ex == null) {
                            ContainerListCallback callback = o.getBody(ContainerListCallback.class);
                            if (callback.hostAdapterReference == null) {
                                callback.hostAdapterReference = ContainerHostDataCollectionService
                                        .getDefaultHostAdapter(getHost());
                            }
                            updateContainerStates(callback, containerStates, containerHostLink);
                        } else {
                            unlockCurrentDataCollectionForHost(containerHostLink);
                        }
                    }));
        }
    });
}

From source file:ai.susi.server.api.aaa.LoginService.java

/**
 * Check if the requesting user is blocked because of too many invalid login attempts
 * @post the query as used in serviceImpl
 * @param authorization the authorization as used in serviceImpl
 * @param permissions the permissions as used in serviceImpl
 * @throws APIException if the user is blocked
  */// ww w  .  j ava 2  s . c  o  m
private void checkInvalidLogins(Query post, Authorization authorization, JsonObjectWithDefault permissions)
        throws APIException {

    // is already blocked?
    long blockedUntil = permissions.getLong("blockedUntil");
    if (blockedUntil != 0) {
        if (blockedUntil > Instant.now().getEpochSecond()) {
            Log.getLog().info(
                    "Blocked ip " + post.getClientHost() + " because of too many invalid login attempts.");
            throw new APIException(403, "Too many invalid login attempts. Try again in "
                    + (blockedUntil - Instant.now().getEpochSecond()) + " seconds");
        } else {
            authorization.setPermission(this, "blockedUntil", 0);
        }
    }

    // check if too many invalid login attempts were made already
    JSONObject invalidLogins = authorization.getAccounting().getRequests(this.getClass().getCanonicalName());
    long period = permissions.getLong("periodSeconds", 600) * 1000; // get time period in which wrong logins are counted (e.g. the last 10 minutes)
    int counter = 0;
    for (String key : invalidLogins.keySet()) {
        if (Long.parseLong(key, 10) > System.currentTimeMillis() - period)
            counter++;
    }
    if (counter > permissions.getInt("maxInvalidLogins", 10)) {
        authorization.setPermission(this, "blockedUntil",
                Instant.now().getEpochSecond() + permissions.getInt("blockTimeSeconds", 120));
        throw new APIException(403, "Too many invalid login attempts. Try again in "
                + permissions.getInt("blockTimeSeconds", 120) + " seconds");
    }
}

From source file:com.vmware.photon.controller.api.client.resource.VmApiTest.java

@Test
public void testPerformRestartOperation() throws IOException {
    Task responseTask = new Task();
    responseTask.setId("12345");
    responseTask.setState("QUEUED");
    responseTask.setQueuedTime(Date.from(Instant.now()));

    ObjectMapper mapper = new ObjectMapper();
    String serializedTask = mapper.writeValueAsString(responseTask);

    setupMocks(serializedTask, HttpStatus.SC_CREATED);

    VmApi vmApi = new VmApi(restClient);

    Task task = vmApi.performRestartOperation("foo");
    assertEquals(task, responseTask);/*  w w w  . ja  va2  s . c  o m*/
}

From source file:retsys.client.controller.PurchaseOrderConfirmController.java

@Override
Object buildRequestMsg() {//from   w w w .ja v  a  2s. c  o m
    PurchaseOrder po = new PurchaseOrder();
    po.setId(Integer.parseInt(po_no.getText()));
    po.setDate(Date.from(Instant.now()));

    Project projectObj = new Project();
    projectObj.setId(splitId(project.getText()));
    po.setProject(projectObj);

    po.setDeliveryAddress(delivery_address.getText());

    Vendor vendorObj = new Vendor();
    vendorObj.setId(splitId(vendor.getText()));
    po.setVendor(vendorObj);

    Iterator<POItem> items = poDetail.getItems().iterator();
    List<PurchaseOrderDetail> poDetails = new ArrayList<>();

    while (items.hasNext()) {
        POItem poItem = items.next();
        PurchaseOrderDetail poDetail = new PurchaseOrderDetail();

        Item item = new Item();
        item.setId(splitId(poItem.getName().get()));
        poDetail.setItem(item);

        poDetail.setId(poItem.getId().get());
        poDetail.setQuantity(poItem.getQuantity().get());
        poDetail.setConfirm(poItem.getConfirm().get() ? "Y" : "N");
        poDetail.setReceivedDate(DateUtils.asDate(poItem.getReceivedDate().get()));
        poDetail.setBillNo(poItem.getBillNo().get());
        poDetail.setSupervisor(poItem.getSupervisor().get());

        poDetails.add(poDetail);
    }

    po.setPurchaseOrderDetail(poDetails);

    return po;
}