Example usage for java.time ZonedDateTime from

List of usage examples for java.time ZonedDateTime from

Introduction

In this page you can find the example usage for java.time ZonedDateTime from.

Prototype

public static ZonedDateTime from(TemporalAccessor temporal) 

Source Link

Document

Obtains an instance of ZonedDateTime from a temporal object.

Usage

From source file:com.buffalokiwi.aerodrome.Aerodrome.java

private static void shipOrders(final JetAPIOrder orderApi) throws APIException, JetException {
    for (final String jetOrderId : orderApi.getOrderStatusTokens(OrderStatus.ACK, false)) {
        //..Get the order detail 
        final OrderRec order = orderApi.getOrderDetail(jetOrderId);

        //..A list of shipments 
        //..You can split the order up into however many shipments you want.
        final List<ShipmentRec> shipments = new ArrayList<>();

        //..a list of items in a shipment 
        final List<ShipmentItemRec> shipmentItems = new ArrayList<>();

        //..Create a return address object 
        final AddressRec returnAddress = new AddressRec("123 Sesame Street", "Suite 100", "Sesame", "AK",
                "38473");

        //..Create an rma number (can be custom for each item if you want)
        final String rmaNumber = "1234RMA";

        //..Turn those into ack order records
        for (final OrderItemRec item : order.getOrderItems()) {
            //..Create a builder for a new ShipmentItem by converting the retrieved
            //  order item to a Shipment Item
            final ShipmentItemRec.Builder builder = ShipmentItemRec.fromOrderItem(item);

            //..You can modify the quantity shipped or cancelled here, or just fulfill as it was ordered
            //..like this:
            //builder.setQuantity( 1 );
            //builder.setCancelQuantity( 1 );

            //...Set the return address
            builder.setReturnTo(returnAddress);

            //..Set the rma number if desired
            builder.setRmaNumber(rmaNumber);

            //..Build the item and add it to the items list 
            shipmentItems.add(builder.build());
        }/*from w w w. ja  va 2  s .  c o  m*/

        //..Build a shipment for the items in the order
        //..You can create multiple shipments, and also mix cancellations 
        //  with shipments.
        final ShipmentRec shipment = new ShipmentRec.Builder()
                .setCarrier(order.getOrderDetail().getRequestShippingCarrier())
                .setTrackingNumber("Z123456780123456").setShipmentDate(new JetDate())
                .setExpectedDeliveryDate(new JetDate(ZonedDateTime.from(Instant.now())
                        .withZoneSameInstant(ZoneId.systemDefault()).plusDays(2)))
                .setShipFromZip("38473").setPickupDate(new JetDate()).setItems(shipmentItems).build();

        //..Add it to the list of shipments you're sending out.
        shipments.add(shipment);

        //..Create the final request object to tell jet about the shipment
        final ShipRequestRec shipmentRequest = new ShipRequestRec("", shipments);

        //..Send the shipment to jet
        orderApi.sendPutShipOrder(jetOrderId, shipmentRequest);
    }
}