List of usage examples for java.time.temporal ChronoField MINUTE_OF_HOUR
ChronoField MINUTE_OF_HOUR
To view the source code for java.time.temporal ChronoField MINUTE_OF_HOUR.
Click Source Link
From source file:Main.java
public static void main(String[] args) { LocalTime l = LocalTime.now(); System.out.println(l.get(ChronoField.MINUTE_OF_HOUR)); }
From source file:Main.java
public static void main(String[] args) { LocalTime l = LocalTime.now(); System.out.println(l.range(ChronoField.MINUTE_OF_HOUR)); }
From source file:Main.java
public static void main(String[] args) { LocalTime l = LocalTime.now(); System.out.println(l.getLong(ChronoField.MINUTE_OF_HOUR)); }
From source file:Main.java
public static void main(String[] args) { DateTimeFormatter formatter = new DateTimeFormatterBuilder().appendValue(ChronoField.HOUR_OF_DAY) .appendLiteral(":").appendValue(ChronoField.MINUTE_OF_HOUR).toFormatter(); System.out.println(formatter.format(LocalDateTime.now())); }
From source file:com.github.aptd.simulation.datamodel.CXMLReader.java
@Override @SuppressWarnings("unchecked") public final IExperiment get(final IFactory p_factory, final String p_datamodel, final long p_simulationsteps, final boolean p_parallel, final String p_timemodel, final Supplier<RealDistribution> p_platformchangedurationdistributionsupplier, final int p_numberofpassengers, final double p_lightbarrierminfreetime, final double p_delayseconds) { try (final FileInputStream l_stream = new FileInputStream(p_datamodel)) { final Asimov l_model = (Asimov) m_context.createUnmarshaller().unmarshal(l_stream); // time definition final Instant l_starttime = ZonedDateTime.now(ZoneId.systemDefault()) .with(ChronoField.CLOCK_HOUR_OF_DAY, 8).with(ChronoField.MINUTE_OF_HOUR, 45) .with(ChronoField.SECOND_OF_MINUTE, 0).with(ChronoField.NANO_OF_SECOND, 0) .with(ChronoField.DAY_OF_MONTH, 3).with(ChronoField.MONTH_OF_YEAR, 10) .with(ChronoField.YEAR, 2017).toInstant(); final ITime l_time = "jump".equals(p_timemodel) ? new CJumpTime(l_starttime, p_simulationsteps) : new CStepTime(l_starttime, Duration.ofSeconds(1), p_simulationsteps); final CMessenger l_messenger = new CMessenger(); final Set<IAction> l_actionsfrompackage = CCommon.actionsFromPackage().collect(Collectors.toSet()); // asl agent definition final Map<String, String> l_agentdefs = agents(l_model.getAi()); // macro (train-network) and microscopic model final Map<String, IPlatform<?>> l_platform = platform(l_model.getNetwork(), l_agentdefs, p_factory, l_time);/*w ww. jav a2s .c o m*/ final Map<String, IStation<?>> l_station = station(l_model.getNetwork(), l_agentdefs, p_factory, l_time, l_platform); final Pair<Map<String, ITrain<?>>, Map<String, IDoor<?>>> l_train = train(l_model.getNetwork(), l_agentdefs, p_factory, l_time, p_lightbarrierminfreetime); final Map<String, IElement<?>> l_agents = new HashMap<>(); l_agents.putAll(l_platform); l_agents.putAll(l_station); l_agents.putAll(l_train.getLeft()); l_agents.putAll(l_train.getRight()); final CExperiment l_experiment = new CExperiment(p_simulationsteps, p_parallel, IStatistic.EMPTY, l_agents, l_time, l_messenger); // @todo create passengersources and their passenger generators according to scenario definition final IElement.IGenerator<IPassenger<?>> l_passengergenerator = passengergenerator(p_factory, "+!activate <-\n state/transition\n.", l_actionsfrompackage, l_time); l_experiment.addAgent("passengersource_test", passengersourcegenerator(p_factory, "+!activate <-\n state/transition\n.", l_actionsfrompackage, l_time).generatesingle(new UniformRealDistribution(0.0, 1.0), l_time.current().toEpochMilli(), p_numberofpassengers, l_passengergenerator, l_experiment, l_agents.get("toy-node-1"), p_platformchangedurationdistributionsupplier.get())); l_messenger.experiment(l_experiment); // experiment (executable model) return l_experiment; } catch (final Exception l_execption) { throw new CRuntimeException(l_execption); } }
From source file:msi.gama.util.GamaDate.java
private static Temporal parse(final IScope scope, final String original, final DateTimeFormatter df) { if (original == null || original.isEmpty() || original.equals("now")) { return LocalDateTime.now(GamaDateType.DEFAULT_ZONE); }// w w w . j av a 2 s. c om Temporal result = null; if (df != null) { try { final TemporalAccessor ta = df.parse(original); if (ta instanceof Temporal) { return (Temporal) ta; } if (!ta.isSupported(ChronoField.YEAR) && !ta.isSupported(ChronoField.MONTH_OF_YEAR) && !ta.isSupported(ChronoField.DAY_OF_MONTH)) { if (ta.isSupported(ChronoField.HOUR_OF_DAY)) { return LocalTime.from(ta); } } if (!ta.isSupported(ChronoField.HOUR_OF_DAY) && !ta.isSupported(ChronoField.MINUTE_OF_HOUR) && !ta.isSupported(ChronoField.SECOND_OF_MINUTE)) { return LocalDate.from(ta); } return LocalDateTime.from(ta); } catch (final DateTimeParseException e) { e.printStackTrace(); } GAMA.reportAndThrowIfNeeded(scope, GamaRuntimeException.warning( "The date " + original + " can not correctly be parsed by the pattern provided", scope), false); return parse(scope, original, null); } String dateStr; try { // We first make sure all date fields have the correct length and // the string is correctly formatted String string = original; if (!original.contains("T") && original.contains(" ")) { string = StringUtils.replaceOnce(original, " ", "T"); } final String[] base = string.split("T"); final String[] date = base[0].split("-"); String other; if (base.length == 1) { other = "00:00:00"; } else { other = base[1]; } String year, month, day; if (date.length == 1) { // ISO basic date format year = date[0].substring(0, 4); month = date[0].substring(4, 6); day = date[0].substring(6, 8); } else { year = date[0]; month = date[1]; day = date[2]; } if (year.length() == 2) { year = "20" + year; } if (month.length() == 1) { month = '0' + month; } if (day.length() == 1) { day = '0' + day; } dateStr = year + "-" + month + "-" + day + "T" + other; } catch (final Exception e1) { throw GamaRuntimeException.error("The date " + original + " is not correctly formatted. Please refer to the ISO date/time format", scope); } try { result = LocalDateTime.parse(dateStr); } catch (final DateTimeParseException e) { try { result = OffsetDateTime.parse(dateStr); } catch (final DateTimeParseException e2) { try { result = ZonedDateTime.parse(dateStr); } catch (final DateTimeParseException e3) { throw GamaRuntimeException.error( "The date " + original + " is not correctly formatted. Please refer to the ISO date/time format", scope); } } } return result; }
From source file:com.thinkbiganalytics.integration.IntegrationTestBase.java
private ServiceLevelAgreementGroup createFeedProcessingDeadlineSla(String feedName, String feedId, LocalDateTime deadline, String noLaterThanHours) { int hourOfDay = deadline.get(ChronoField.HOUR_OF_DAY); int minuteOfHour = deadline.get(ChronoField.MINUTE_OF_HOUR); String cronExpression = String.format("0 %s %s 1/1 * ? *", minuteOfHour, hourOfDay); ServiceLevelAgreementGroup sla = new ServiceLevelAgreementGroup(); String time = deadline.format(DateTimeFormatter.ofPattern("HH:mm")); sla.setName("Before " + time + " (cron: " + cronExpression + ")"); sla.setDescription("The feed should complete before given date and time"); List<ServiceLevelAgreementRule> rules = new ArrayList<>(); ServiceLevelAgreementRule rule = new ServiceLevelAgreementRule(); rule.setName("Feed Processing deadline"); rule.setDisplayName("Feed Processing deadline"); rule.setDescription("Ensure a Feed processes data by a specified time"); rule.setObjectClassType("com.thinkbiganalytics.metadata.sla.api.core.FeedOnTimeArrivalMetric"); rule.setObjectShortClassType("FeedOnTimeArrivalMetric"); rule.setCondition(ObligationGroup.Condition.REQUIRED); rule.setProperties(newFieldRuleProperties(newFieldRuleProperty("FeedName", "feedName", feedName), newFieldRuleProperty("ExpectedDeliveryTime", "cronString", cronExpression), newFieldRuleProperty("NoLaterThanTime", "lateTime", noLaterThanHours), newFieldRuleProperty("NoLaterThanUnits", "lateUnits", "hrs"))); rules.add(rule);//from w w w.j a v a2 s . c om sla.setRules(rules); Response response = given(ServiceLevelAgreementRestController.V1_FEEDMGR_SLA).body(sla).when() .post(String.format("feed/%s", feedId)); response.then().statusCode(HTTP_OK); return response.as(ServiceLevelAgreementGroup.class); }
From source file:org.sleuthkit.autopsy.timeline.ShowInTimelineDialog.java
/** * Common Private Constructor//ww w.j ava 2 s . c o m * * @param controller The controller for this Dialog. * @param eventIDS A List of eventIDs to present to the user to choose * from. */ @NbBundle.Messages({ "ShowInTimelineDialog.amountValidator.message=The entered amount must only contain digits." }) private ShowInTimelineDialog(TimeLineController controller, List<Long> eventIDS) { this.controller = controller; //load dialog content fxml final String name = "nbres:/" + StringUtils.replace(ShowInTimelineDialog.class.getPackage().getName(), ".", "/") + "/ShowInTimelineDialog.fxml"; // NON-NLS try { FXMLLoader fxmlLoader = new FXMLLoader(new URL(name)); fxmlLoader.setRoot(contentRoot); fxmlLoader.setController(this); fxmlLoader.load(); } catch (IOException ex) { LOGGER.log(Level.SEVERE, "Unable to load FXML, node initialization may not be complete.", ex); //NON-NLS } //assert that fxml loading happened correctly assert eventTable != null : "fx:id=\"eventTable\" was not injected: check your FXML file 'ShowInTimelineDialog.fxml'."; assert typeColumn != null : "fx:id=\"typeColumn\" was not injected: check your FXML file 'ShowInTimelineDialog.fxml'."; assert dateTimeColumn != null : "fx:id=\"dateTimeColumn\" was not injected: check your FXML file 'ShowInTimelineDialog.fxml'."; assert amountSpinner != null : "fx:id=\"amountsSpinner\" was not injected: check your FXML file 'ShowInTimelineDialog.fxml'."; assert unitComboBox != null : "fx:id=\"unitChoiceBox\" was not injected: check your FXML file 'ShowInTimelineDialog.fxml'."; //validat that spinner has a integer in the text field. validationSupport.registerValidator(amountSpinner.getEditor(), false, Validator.createPredicateValidator( NumberUtils::isDigits, Bundle.ShowInTimelineDialog_amountValidator_message())); //configure dialog properties PromptDialogManager.setDialogIcons(this); initModality(Modality.APPLICATION_MODAL); //add scenegraph loaded from fxml to this dialog. DialogPane dialogPane = getDialogPane(); dialogPane.setContent(contentRoot); //add buttons to dialog dialogPane.getButtonTypes().setAll(SHOW, ButtonType.CANCEL); ///configure dialog controls amountSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 1000)); amountSpinner.getValueFactory().setConverter(new IntegerStringConverter() { /** * Convert the String to an Integer using Integer.valueOf, but if * that throws a NumberFormatException, reset the spinner to the * last valid value. * * @param string The String to convert * * @return The Integer value of string. */ @Override public Integer fromString(String string) { try { return super.fromString(string); } catch (NumberFormatException ex) { return amountSpinner.getValue(); } } }); unitComboBox.setButtonCell(new ChronoFieldListCell()); unitComboBox.setCellFactory(comboBox -> new ChronoFieldListCell()); unitComboBox.getItems().setAll(SCROLL_BY_UNITS); unitComboBox.getSelectionModel().select(ChronoField.MINUTE_OF_HOUR); typeColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getEventType())); typeColumn.setCellFactory(param -> new TypeTableCell<>()); dateTimeColumn.setCellValueFactory(param -> new SimpleObjectProperty<>(param.getValue().getStartMillis())); dateTimeColumn.setCellFactory(param -> new DateTimeTableCell<>()); //add events to table eventTable.getItems().setAll( eventIDS.stream().map(controller.getEventsModel()::getEventById).collect(Collectors.toSet())); eventTable.setPrefHeight(Math.min(200, 24 * eventTable.getItems().size() + 28)); }