Example usage for java.time ZoneId systemDefault

List of usage examples for java.time ZoneId systemDefault

Introduction

In this page you can find the example usage for java.time ZoneId systemDefault.

Prototype

public static ZoneId systemDefault() 

Source Link

Document

Gets the system default time-zone.

Usage

From source file:software.reinvent.dependency.parser.service.ArtifactDependencyGraph.java

/**
 * Adds a model as {@link ArtifactParent}. Parses especially the managed dependencies to make sure that the
 * dependencies which are child of the parent will contain the versions.
 *
 * @param parent the model to add/*from w  ww. ja  v a2s  . c  o  m*/
 */
private void addParent(final Model parent) {
    final Properties properties = parent.getProperties();
    final List<Dependency> managedDependencies = parent.getDependencyManagement().getDependencies();
    setVersionToDepencies(parent, managedDependencies);
    addDependencies(managedDependencies);
    final ArtifactParent artifactParent = new ArtifactParent(parent.getGroupId(), parent.getArtifactId(),
            parent.getVersion(), LocalDateTime.ofInstant(
                    Instant.ofEpochMilli(parent.getPomFile().lastModified()), ZoneId.systemDefault()));
    if (artifactParents.contains(artifactParent)) {
        artifactParents.stream().filter(x -> x.equals(artifactParent)).findFirst().ifPresent(x -> {
            if (x.getFileDate().isBefore(artifactParent.getFileDate())) {
                artifactParents.remove(artifactParent);
            }
        });
        artifactParents.add(artifactParent);
    } else {
        artifactParents.add(artifactParent);
    }
}

From source file:org.dbflute.solr.cbean.SolrQueryBuilder.java

public static String queryBuilderForRangeSearch(String solrFieldName, LocalDate from, LocalDate to) {
    Date fromDate = from == null ? null
            : Date.from(ZonedDateTime.of(from, LocalTime.MIDNIGHT, ZoneId.systemDefault()).toInstant());
    Date toDate = to == null ? null
            : Date.from(ZonedDateTime.of(to, LocalTime.MIDNIGHT, ZoneId.systemDefault()).toInstant());
    return queryBuilderForRangeSearch(solrFieldName, fromDate, toDate);
}

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

/**
 * Initializes the controller class./*from   w  ww  .  ja  v a 2  s  .  c o m*/
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    dc_date.setValue(LocalDate.now());

    material_name.setCellValueFactory(new PropertyValueFactory<DCItem, String>("name"));
    brand_name.setCellValueFactory(new PropertyValueFactory<DCItem, String>("brand"));
    model_code.setCellValueFactory(new PropertyValueFactory<DCItem, String>("model"));
    units.setCellValueFactory(new PropertyValueFactory<DCItem, String>("model"));
    quantity.setCellValueFactory(new PropertyValueFactory<DCItem, Integer>("quantity"));
    amount.setCellValueFactory(new PropertyValueFactory<DCItem, Integer>("amount"));

    dcDetail.getColumns().setAll(material_name, brand_name, model_code, quantity, amount);
    // TODO

    AutoCompletionBinding<Item> bindForTxt_name = TextFields.bindAutoCompletion(txt_name,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<Item>>() {

                @Override
                public Collection<Item> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<Item> list = null;
                    try {
                        LovHandler lovHandler = new LovHandler("items", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<Item>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<Item>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }
            }, new StringConverter<Item>() {

                @Override
                public String toString(Item object) {
                    System.out.println("here..." + object);
                    return object.getName() + " (ID:" + object.getId() + ")";
                }

                @Override
                public Item fromString(String string) {
                    throw new UnsupportedOperationException();
                }
            });
    //event handler for setting other item fields with values from selected Item object
    //fires after autocompletion
    bindForTxt_name.setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<Item>>() {

        @Override
        public void handle(AutoCompletionBinding.AutoCompletionEvent<Item> event) {
            Item item = event.getCompletion();
            //fill other item related fields
            txt_name.setUserData(item.getId());
            txt_brand.setText(item.getBrand());
            txt_model.setText(null); // item doesn't have this field. add??
            txt_rate.setText(String.valueOf(item.getRate()));
        }
    });

    AutoCompletionBinding<DeliveryChallan> bindForProject = TextFields.bindAutoCompletion(project,
            new Callback<AutoCompletionBinding.ISuggestionRequest, Collection<DeliveryChallan>>() {

                @Override
                public Collection<DeliveryChallan> call(AutoCompletionBinding.ISuggestionRequest param) {
                    List<DeliveryChallan> list = null;
                    try {
                        LovHandler lovHandler = new LovHandler("deliverychallans", "name");
                        String response = lovHandler.getSuggestions(param.getUserText());
                        list = (List<DeliveryChallan>) new JsonHelper().convertJsonStringToObject(response,
                                new TypeReference<List<DeliveryChallan>>() {
                                });
                    } catch (IOException ex) {
                        Logger.getLogger(ProjectController.class.getName()).log(Level.SEVERE, null, ex);
                    }

                    return list;
                }
            }, new StringConverter<DeliveryChallan>() {

                @Override
                public String toString(DeliveryChallan object) {
                    System.out.println("here..." + object);

                    String strDate = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM).format(LocalDateTime
                            .ofInstant(object.getChallanDate().toInstant(), ZoneId.systemDefault()));
                    return "Project:" + object.getProject().getName() + " DC Date:" + strDate + " DC No.:"
                            + object.getId();
                }

                @Override
                public DeliveryChallan fromString(String string) {
                    throw new UnsupportedOperationException();
                }
            });

    bindForProject
            .setOnAutoCompleted(new EventHandler<AutoCompletionBinding.AutoCompletionEvent<DeliveryChallan>>() {

                @Override
                public void handle(AutoCompletionBinding.AutoCompletionEvent<DeliveryChallan> event) {
                    DeliveryChallan dc = event.getCompletion();
                    dc_no.setText(dc.getId().toString());
                    dc_date.setValue(LocalDateTime
                            .ofInstant(dc.getChallanDate().toInstant(), ZoneId.systemDefault()).toLocalDate());
                    dc_no.setText(dc.getId().toString());
                    project.setText(dc.getProject().getName() + " (ID:" + dc.getProject().getId() + ")");
                    deliverymode.setText(dc.getDeliveryMode());
                    concernperson.setText(dc.getConcernPerson());

                    ObservableList<DCItem> items = FXCollections.observableArrayList();
                    Iterator detailsIt = dc.getDeliveryChallanDetail().iterator();
                    while (detailsIt.hasNext()) {
                        DeliveryChallanDetail detail = (DeliveryChallanDetail) detailsIt.next();
                        Item item = detail.getItem();
                        int id = item.getId();
                        String site = item.getSite();
                        String name = item.getName();
                        String brand = item.getBrand();
                        String model = null;
                        int rate = item.getRate().intValue();
                        int quantity = detail.getQuantity();
                        int amount = detail.getAmount();
                        String units = detail.getUnits();

                        items.add(new DCItem(id, name + " (ID:" + id + ")", brand, model, rate, quantity, units,
                                amount));
                    }
                    dcDetail.setItems(items);

                    populateAuditValues(dc);

                }
            });

    txt_qty.focusedProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            if (!newValue) {
                calcAmount();
            }
        }
    });
}

From source file:org.codelibs.fess.app.web.admin.backup.AdminBackupAction.java

private static StringBuilder appendJson(final String field, final Object value, final StringBuilder buf) {
    buf.append('"').append(StringEscapeUtils.escapeJson(field)).append('"').append(':');
    if (value == null) {
        buf.append("null");
    } else if (value instanceof LocalDateTime) {
        final String format = ((LocalDateTime) value).atZone(ZoneId.systemDefault())
                .withZoneSameInstant(ZoneId.of("UTC")).format(ISO_8601_FORMATTER);
        buf.append('"').append(StringEscapeUtils.escapeJson(format)).append('"');
    } else if (value instanceof String[]) {
        final String json = Arrays.stream((String[]) value)
                .map(s -> "\"" + StringEscapeUtils.escapeJson(s) + "\"").collect(Collectors.joining(","));
        buf.append('[').append(json).append(']');
    } else if (value instanceof List) {
        final String json = ((List<?>) value).stream()
                .map(s -> "\"" + StringEscapeUtils.escapeJson(s.toString()) + "\"")
                .collect(Collectors.joining(","));
        buf.append('[').append(json).append(']');
    } else if (value instanceof Map) {
        buf.append('{');
        final String json = ((Map<?, ?>) value).entrySet().stream().map(e -> {
            final StringBuilder tempBuf = new StringBuilder();
            appendJson(e.getKey().toString(), e.getValue(), tempBuf);
            return tempBuf.toString();
        }).collect(Collectors.joining(","));
        buf.append(json);//  ww w  .jav  a 2s  .c  om
        buf.append('}');
    } else if (value instanceof Long || value instanceof Integer) {
        buf.append(((Number) value).longValue());
    } else if (value instanceof Number) {
        buf.append(((Number) value).doubleValue());
    } else {
        buf.append('"').append(StringEscapeUtils.escapeJson(value.toString())).append('"');
    }
    return buf;
}

From source file:org.millr.slick.servlets.item.EditItemServlet.java

private Date convertDate(String publishString) {

    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm", Locale.ENGLISH);
    LocalDateTime dateTime = LocalDateTime.parse(publishString, formatter);

    Date publishDate = Date.from(dateTime.atZone(ZoneId.systemDefault()).toInstant());

    return publishDate;
}

From source file:net.ceos.project.poi.annotated.core.CellFormulaHandler.java

/**
 * Apply a Date value to the cell./*w  w w . j a v  a  2 s.  c  o m*/
 * 
 * @param configCriteria
 *            the {@link XConfigCriteria}
 * @param object
 *            the object
 * @param cell
 *            the {@link Cell} to use
 * @throws IllegalAccessException
 * @throws ConverterException
 */
protected static void localDateHandler(final XConfigCriteria configCriteria, final Object object,
        final Cell cell) throws IllegalAccessException, ConverterException {
    LocalDate date = (LocalDate) configCriteria.getField().get(object);
    if (StringUtils.isNotBlank(configCriteria.getElement().transformMask())) {
        // apply transformation mask
        String decorator = configCriteria.getElement().transformMask();
        convertDate(cell, Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant()), decorator);
    } else if (StringUtils.isNotBlank(configCriteria.getElement().formatMask())) {
        // apply format mask
        CellValueHandler.consumeValue(cell, Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant()));
    } else {
        // apply default date mask
        CellValueHandler.consumeValue(cell, Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant()));
    }
}

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

@Override
protected Object buildRequestMsg() {
    CreditNote creditNote = new CreditNote();
    if (!creditNoteNo.getText().isEmpty()) {
        // update operation
        creditNote.setId(Integer.parseInt(creditNoteNo.getText()));
    }//from  w  w  w .  j  av  a 2s  . c  om
    Vendor vendorObj = new Vendor();
    vendorObj.setId(splitId(vendor.getText()));
    creditNote.setVendor(vendorObj);

    Date date = Date.from(Instant.from(creationDate.getValue().atStartOfDay(ZoneId.systemDefault())));
    creditNote.setCreationDate(date);
    creditNote.setTotalAmount(Double.parseDouble(totalCredit.getText()));
    creditNote.setRemarks(remarks.getText());

    List<CreditNoteDetail> details = new ArrayList<>();
    Iterator<CreditNoteItem> items = creditNoteDetail.getItems().iterator();

    while (items.hasNext()) {
        CreditNoteItem creditNoteItem = items.next();
        Item item = new Item();
        //item.setId(getId(creditNoteItem.getItemName().get()));
        item.setId(splitId(creditNoteItem.getItemName().get()));
        if (creditNoteItem.getId().get() != 0) {
            // update operation
            details.add(new CreditNoteDetail(creditNoteItem.getId().get(), item,
                    creditNoteItem.getReturnQuantity().get(), creditNoteItem.getItemAmount().get(),
                    creditNoteItem.getConfirm().get()));
        } else {
            details.add(new CreditNoteDetail(item, creditNoteItem.getReturnQuantity().get(),
                    creditNoteItem.getItemAmount().get(), creditNoteItem.getConfirm().get()));
        }
    }

    creditNote.setCreditNoteDetails(details);

    return creditNote;
}

From source file:org.dhatim.fastexcel.Correctness.java

@Test
public void singleWorksheet() throws Exception {
    String sheetName = "Worksheet 1";
    String stringValue = "Sample text with chars to escape : < > & \\ \" ' ~        ";
    Date dateValue = new Date();
    LocalDateTime localDateTimeValue = LocalDateTime.now();
    ZoneId timezone = ZoneId.of("Australia/Sydney");
    ZonedDateTime zonedDateValue = ZonedDateTime.ofInstant(dateValue.toInstant(), timezone);
    double doubleValue = 1.234;
    int intValue = 2_016;
    long longValue = 2_016_000_000_000L;
    BigDecimal bigDecimalValue = BigDecimal.TEN;
    byte[] data = writeWorkbook(wb -> {
        Worksheet ws = wb.newWorksheet(sheetName);
        int i = 1;
        ws.value(i, i++, stringValue);/*from ww  w. j a  va 2 s .c  om*/
        ws.value(i, i++, dateValue);
        ws.value(i, i++, localDateTimeValue);
        ws.value(i, i++, zonedDateValue);
        ws.value(i, i++, doubleValue);
        ws.value(i, i++, intValue);
        ws.value(i, i++, longValue);
        ws.value(i, i++, bigDecimalValue);
        try {
            ws.finish();
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    });

    // Check generated workbook with Apache POI
    XSSFWorkbook xwb = new XSSFWorkbook(new ByteArrayInputStream(data));
    assertThat(xwb.getActiveSheetIndex()).isEqualTo(0);
    assertThat(xwb.getNumberOfSheets()).isEqualTo(1);
    XSSFSheet xws = xwb.getSheet(sheetName);
    @SuppressWarnings("unchecked")
    Comparable<XSSFRow> row = (Comparable) xws.getRow(0);
    assertThat(row).isNull();
    int i = 1;
    assertThat(xws.getRow(i).getCell(i++).getStringCellValue()).isEqualTo(stringValue);
    assertThat(xws.getRow(i).getCell(i++).getDateCellValue()).isEqualTo(dateValue);
    // Check zoned timestamps have the same textual representation as the Dates extracted from the workbook
    // (Excel date serial numbers do not carry timezone information)
    assertThat(DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(ZonedDateTime
            .ofInstant(xws.getRow(i).getCell(i++).getDateCellValue().toInstant(), ZoneId.systemDefault())))
                    .isEqualTo(DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(localDateTimeValue));
    assertThat(DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(ZonedDateTime
            .ofInstant(xws.getRow(i).getCell(i++).getDateCellValue().toInstant(), ZoneId.systemDefault())))
                    .isEqualTo(DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(zonedDateValue));
    assertThat(xws.getRow(i).getCell(i++).getNumericCellValue()).isEqualTo(doubleValue);
    assertThat(xws.getRow(i).getCell(i++).getNumericCellValue()).isEqualTo(intValue);
    assertThat(xws.getRow(i).getCell(i++).getNumericCellValue()).isEqualTo(longValue);
    assertThat(new BigDecimal(xws.getRow(i).getCell(i++).getRawValue())).isEqualTo(bigDecimalValue);
}

From source file:org.dbflute.solr.cbean.SolrQueryBuilder.java

public static String queryBuilderForRangeSearch(String solrFieldName, LocalDateTime from, LocalDateTime to) {
    Date fromDate = from == null ? null : Date.from(ZonedDateTime.of(from, ZoneId.systemDefault()).toInstant());
    Date toDate = to == null ? null : Date.from(ZonedDateTime.of(to, ZoneId.systemDefault()).toInstant());
    return queryBuilderForRangeSearch(solrFieldName, fromDate, toDate);
}

From source file:com.github.horrorho.inflatabledonkey.args.ArgsFactory.java

static String mapTimestamp(String date) {
    return "" + LocalDate.parse(date, DateTimeFormatter.ISO_DATE).atStartOfDay(ZoneId.systemDefault())
            .toEpochSecond();/*from w w  w.j  a va2s  . c  o  m*/
}