@Override public void parse(Message m) { String target = m.param(); if (!m.param().startsWith("#")) target = m.sender(); if (m.trailing().equals("TIME")) { String time = String.format( "%s %02d:%02d:%02d ", LocalDate.now().toString(), LocalTime.now().getHour(), LocalTime.now().getMinute(), LocalTime.now().getSecond()); m.notice(m.sender(), String.format("TIME %s", time)); } if (m.command().equals("PRIVMSG")) { if (m.botCommand().equals("time")) { if (m.hasBotParams()) { for (int i = 0; i < m.botParamsArray().length; i++) { m.pm(m.botParamsArray()[i], "TIME"); requests.put(m.botParamsArray()[i], target); } } } } if (m.command().equals("NOTICE")) { if (requests.containsKey(m.sender())) { if (m.trailing().startsWith("TIME")) { String version = m.trailing().substring(5, m.trailing().length() - 1); Server.say(requests.get(m.sender()), "[" + m.sender() + "] Current Time: " + version); requests.remove(m.sender()); } } } }
private void loadScheduleTimesFromDatabase() { scheduleTimeList.add( new ScheduleTime(DayOfWeek.MONDAY, LocalTime.now(), Duration.ofMinutes(60))); scheduleTimeList.add( new ScheduleTime(DayOfWeek.TUESDAY, LocalTime.now(), Duration.ofMinutes(60))); scheduleTimeList.add( new ScheduleTime(DayOfWeek.THURSDAY, LocalTime.now(), Duration.ofMinutes(3))); }
@Test public void checkPassengerGenerationRuleMax() { PassengerGenerationRule item = PassengerGenerationRule.of(1001, LocalTime.now(), LocalTime.now(), LocalTime.now()); Set<ConstraintViolation<PassengerGenerationRule>> constraintViolations = validator.validate(item, ImitationSourceSequence.class); constraintViolations.forEach(System.out::println); assertEquals(1, constraintViolations.size()); constraintViolations.forEach( constraint -> assertEquals("must be less than or equal toXML 1000", constraint.getMessage())); }
public static void main(String[] args) { // Current Date LocalDateTime today = LocalDateTime.now(); System.out.println("Current DateTime=" + today); // Current Date using LocalDate and LocalTime today = LocalDateTime.of(LocalDate.now(), LocalTime.now()); System.out.println("Current DateTime=" + today); // Creating LocalDateTime by providing input arguments LocalDateTime specificDate = LocalDateTime.of(2014, Month.JANUARY, 1, 10, 10, 30); System.out.println("Specific Date=" + specificDate); // Try creating date by providing invalid inputs // LocalDateTime feb29_2014 = LocalDateTime.of(2014, Month.FEBRUARY, 28, // 25,1,1); // Exception in thread "main" java.time.DateTimeException: // Invalid value for HourOfDay (valid values 0 - 23): 25 // Current date in "Asia/Kolkata", you can get it from ZoneId javadoc LocalDateTime todayKolkata = LocalDateTime.now(ZoneId.of("Asia/Kolkata")); System.out.println("Current Date in IST=" + todayKolkata); // java.time.zone.ZoneRulesException: Unknown time-zone ID: IST // LocalDateTime todayIST = LocalDateTime.now(ZoneId.of("IST")); // Getting date from the base date i.e 01/01/1970 LocalDateTime dateFromBase = LocalDateTime.ofEpochSecond(10000, 0, ZoneOffset.UTC); System.out.println("10000th second time from 01/01/1970= " + dateFromBase); }
private void asyncButtonHandler(ActionEvent event) { this.asyncButton.setDisable(true); this.asyncLabel.setText( String.format("started at %s", LocalTime.now().format(JavaFXClass.TIME_FORMATTER))); new Thread( () -> { Future<LocalTime> task = this.asyncExecutor.submit(this::asyncTask); try { LocalTime finished = task.get(JavaFXClass.ASYNC_SECONDS_ABORT, TimeUnit.SECONDS); Platform.runLater( () -> { this.asyncLabel.setText( String.format( "finished at %s", finished.format(JavaFXClass.TIME_FORMATTER))); this.asyncButton.setDisable(false); }); } catch (TimeoutException ex) { Platform.runLater( () -> { this.asyncLabel.setText( String.format("aborted after %ss", JavaFXClass.ASYNC_SECONDS_ABORT)); this.asyncButton.setDisable(false); }); } catch (ExecutionException | InterruptedException ex) { ex.printStackTrace(); } }) .start(); }
// simualte the streaming data public boolean streamEmulation() throws IOException { String line = null; while (this.cacheContentOfGraphIds.size() < this.size) { AGGraph graph = this.graphMaker.createGraph("http://fefocacheeviction.org/graph" + this.graphID); for (int i = 0; i < this.numberOfTriples; ++i) { if ((line = this.br.readLine()) != null) { line = line.replaceAll("<", ""); line = line.replaceAll(">", ""); String[] parts = line.split(" "); Node s = NodeFactory.createURI(parts[0]); Node p = NodeFactory.createURI(parts[1]); if (parts[2].contains("http")) { Node o = NodeFactory.createURI(parts[2].substring(0, parts[2].length())); graph.add(new Triple(s, p, o)); } else { Node o = NodeFactory.createLiteral(parts[2].substring(1, parts[2].length() - 1)); graph.add(new Triple(s, p, o)); } } else { return false; } } this.cacheContentOfGraphIds.add( new GraphIdCounterPair( "http://fefocacheeviction.org/graph" + (this.graphID++), LocalTime.now())); this.modelGraph = this.graphMaker.createUnion(this.modelGraph, graph); } return true; }
public Order( User user, LocalDate createdAtDate, LocalTime createdAtTime, LocalDate serveAtDate, LocalTime serveAtTime, String orderNumber, String desc) throws NullPointerException { this.createdDate = createdAtDate; this.createdTime = createdAtTime; this.user = user; createdTime = LocalTime.now(); this.serveAtDate = serveAtDate; this.serveAtTime = serveAtTime; this.description = desc; orderedMeals = new ArrayList<>(); number = orderNumber; sspCreatedDate = new SimpleStringProperty(createdDate.toString()); sspCreatedTime = new SimpleStringProperty(createdTime.toString()); sspOrderedMeals = new SimpleStringProperty(); sspUserName = new SimpleStringProperty(this.user.getUserName().get()); sspNumber = new SimpleStringProperty(number.toString()); sspServeAtDate = new SimpleStringProperty(serveAtDate.toString()); sspServeAtTime = new SimpleStringProperty(serveAtTime.toString()); sspPrice = new SimpleStringProperty(); sspDescription = new SimpleStringProperty(description); sspCreatedAtCompact = new SimpleStringProperty(createdDate.toString() + " " + createdTime.toString()); sspServeAtCompact = new SimpleStringProperty(serveAtDate.toString() + " " + serveAtTime.toString()); }
@Test public void should_fail_if_timeTime_as_string_parameter_is_null() { expectException( IllegalArgumentException.class, "The String representing the LocalTime to compare actual with should not be null"); assertThat(LocalTime.now()).isAfterOrEqualTo((String) null); }
public static void main(String args[]) { LocalDate curDate = LocalDate.now(); System.out.println(curDate); LocalTime curTime = LocalTime.now(); System.out.println(curTime); }
@Test public void test() { ZoneId zone1 = ZoneId.of("Europe/Berlin"); ZoneId zone2 = ZoneId.of("Brazil/East"); ZoneId zone3 = ZoneId.of("Europe/London"); LocalTime now1 = LocalTime.now(zone1); LocalTime now2 = LocalTime.now(zone2); System.out.println(now1.isBefore(now2)); // false long hoursBetween = ChronoUnit.HOURS.between(now1, now2); long minutesBetween = ChronoUnit.MINUTES.between(now1, now2); System.out.println(hoursBetween); // -3 System.out.println(minutesBetween); // -239 }
@Override public void execute(Tuple tuple) { opencv_core.IplImage fkImpage = new opencv_core.IplImage(); collector.ack(tuple); String name = tuple.getStringByField("Filename"); int i = name.length() - 1; while (i >= 0 && name.charAt(i) != '\\') i--; if (i >= 0) { name = name.substring(i + 1, name.length()); } if (tuple.contains("F_type")) name = name + tuple.getStringByField("F_type"); name = name + String.valueOf(tuple.getIntegerByField("Pack")) + "_" + String.valueOf(tuple.getIntegerByField("Frame")) + "_" + String.valueOf(tuple.getIntegerByField("Patch")) + "_" + String.valueOf(tuple.getIntegerByField("Scale")) + "_" + String.valueOf(tuple.getIntegerByField("sPatch")) + ".txt"; System.out.println("[ Output ] " + path + name + LocalTime.now()); if (tuple.contains("Image")) { opencv_highgui.imwrite( path + name.substring(0, name.length() - 4) + ".jpg", ((tool.Serializable.Mat) tuple.getValueByField("Image")).toJavaCVMat()); } else { try { FileWriter writer = new FileWriter(path + name, false); System.out.println("zzzzzzzzzzzzzz " + tuple.getFields().get(0)); if (tuple.contains("Feature")) { List<Double> f = (List<Double>) tuple.getValueByField("Feature"); writer.write(String.valueOf(f.size()) + "\n"); for (int j = 0; j < f.size(); j++) { writer.write(String.valueOf(f.get(j)) + " "); } } else if (tuple.contains("Features")) { List<List<Double>> f = (List<List<Double>>) tuple.getValueByField("Features"); writer.write(String.valueOf(f.size()) + "\n"); // System.out.println(String.valueOf(f.size())+"\n"); for (int j = 0; j < f.size(); j++) { writer.write(String.valueOf(f.get(j).size()) + "\n"); for (int k = 0; k < f.get(j).size(); k++) writer.write(String.valueOf(f.get(j).get(k)) + " "); writer.write("\n"); } } else { writer.write(tuple.getFields().get(0)); } writer.flush(); writer.close(); } catch (Exception e) { } } }
private void sendTimeToAll(Session session) { allSessions = session.getOpenSessions(); for (Session sess : allSessions) { try { sess.getBasicRemote().sendText("Local time: " + LocalTime.now().format(timeFormatter)); } catch (IOException ioe) { System.out.println(ioe.getMessage()); } } }
@Test public void testVoteSuccess() { Vote correctVote = new Vote(); correctVote.setRestaurantId(Long.MIN_VALUE); Restaurant restaurant = new Restaurant(); restaurant.setRestaurantId(Long.MIN_VALUE); when(restaurantRepository.findOne(Long.MIN_VALUE)).thenReturn(restaurant); when(votingRepository.findByUser("admin")).thenReturn(null); try { MvcResult successVoteRes = mockMvc .perform( post("/vote") .contentType(MediaType.APPLICATION_JSON) .content(mapper.writeValueAsString(correctVote))) .andExpect(status().isOk()) .andReturn(); String outdatedVoteResString = successVoteRes.getResponse().getContentAsString(); assertTrue(outdatedVoteResString.contains(Status.SUCCESS.getStatusValue())); } catch (Exception e) { fail(); } LocalTime currentTime = LocalTime.now(); if (currentTime.isBefore(RestaurantController.DEADLINE)) { Restaurant votingRestaurant = new Restaurant(); votingRestaurant.setRestaurantId(Long.MAX_VALUE); Voting identicalVoting = new Voting(); identicalVoting.setRestaurant(votingRestaurant); when(votingRepository.findByUser("admin")).thenReturn(identicalVoting); try { MvcResult actualVoteRes = mockMvc .perform( post("/vote") .contentType(MediaType.APPLICATION_JSON) .content(mapper.writeValueAsString(correctVote))) .andExpect(status().isOk()) .andReturn(); String outdatedVoteResString = actualVoteRes.getResponse().getContentAsString(); assertTrue(outdatedVoteResString.contains(Status.SUCCESS.getStatusValue())); } catch (Exception e) { fail(); } } }
@Test public void updateTask() throws Exception { // update existing task Task t = new Task(); Long id = PermanentUserData.tasks.get(0).getId(); t.setName("updated"); t.setRole(new Role(PermanentUserData.tasks.get(0).getRole().getId())); given() .contentType("application/json") .filter(sessionFilter) .body(om.writeValueAsString(t)) .put("/web/" + id.toString()) .then() .statusCode(204); // delete it given() .header(PermanentUserData.tokenHeader) .delete("/m/" + PermanentUserData.tasks.get(0).getId()) .then() .statusCode(204); // test if is recreated with correct values t.setNote("note"); LocalTime moment = LocalTime.now(); int minutes = moment.getMinute(); int hours = moment.getHour(); t.setTime(moment); given() .contentType("application/json") .header(PermanentUserData.tokenHeader) .body(om.writeValueAsString(t)) .put("/m/" + id.toString()) .then() .statusCode(204); try (Connection conn = ds.getConnection(); PreparedStatement ps = conn.prepareStatement("select * from task where name = ?"); ) { ps.setString(1, "updated"); try (ResultSet rs = ps.executeQuery(); ) { rs.next(); assertThat(rs.getString("name"), equalTo("updated")); assertThat(rs.getString("note"), equalTo("note")); assertThat(rs.getTime("time").getMinutes(), equalTo(minutes)); assertThat(rs.getTime("time").getHours(), equalTo(hours)); // rest was set to default assertThat(rs.getBoolean("finished"), equalTo(false)); assertThat(rs.getBoolean("important"), equalTo(false)); assertThat(rs.getBoolean("finished"), equalTo(false)); assertThat(rs.getDate("date"), equalTo(null)); assertThat(rs.getDate("firstDate"), equalTo(null)); } } }
private void addToStats(String subType) { if (sessionProvider == null) return; SessionDetails sessionDetails = sessionProvider.get(); if (sessionDetails != null) { String userId = sessionDetails.userId(); Map<String, SubscriptionStat> subStats = getSubscriptionMap(); if (subStats != null) { SubscriptionStat stat = subStats.get(userId + "~" + subType); if (stat == null) { stat = new SubscriptionStat(); stat.setFirstSubscribed(LocalTime.now()); } stat.setTotalSubscriptions(stat.getTotalSubscriptions() + 1); stat.setActiveSubscriptions(stat.getActiveSubscriptions() + 1); stat.setRecentlySubscribed(LocalTime.now()); subStats.put(userId + "~" + subType, stat); } } }
private LocalTime asyncTask() { try { TimeUnit.SECONDS.sleep( new Random().nextInt(JavaFXClass.ASYNC_SECONDS_MAX - JavaFXClass.ASYNC_SECONDS_MIN + 1) + JavaFXClass.ASYNC_SECONDS_MIN); } catch (InterruptedException ex) { ex.printStackTrace(); } return LocalTime.now(); }
@Test public void testPack() { LocalDate date = LocalDate.now(); LocalTime time = LocalTime.now(); long packed = pack(date, time); LocalDate d1 = PackedLocalDate.asLocalDate(date(packed)); LocalTime t1 = PackedLocalTime.asLocalTime(time(packed)); assertNotNull(d1); assertNotNull(t1); assertEquals(date.toString(), d1.toString()); }
@Test public void testVoteError() { try { Vote wrongVote = new Vote(); wrongVote.setRestaurantId(Long.MAX_VALUE); when(restaurantRepository.findOne(Long.MAX_VALUE)).thenReturn(null); MvcResult wrongIdVoteRes = mockMvc .perform( post("/vote") .contentType(MediaType.APPLICATION_JSON) .content(mapper.writeValueAsString(wrongVote))) .andExpect(status().isOk()) .andReturn(); String wrongIdVoteResponseString = wrongIdVoteRes.getResponse().getContentAsString(); assertTrue(wrongIdVoteResponseString.contains(Status.FAILED.getStatusValue())); assertTrue(wrongIdVoteResponseString.contains(RestaurantController.WRONG_RESTAURANT_MSG)); LocalTime currentTime = LocalTime.now(); if (currentTime.isAfter(RestaurantController.DEADLINE)) { Vote correctVote = new Vote(); correctVote.setRestaurantId(Long.MIN_VALUE); Restaurant restaurant = new Restaurant(); restaurant.setRestaurantId(Long.MIN_VALUE); when(restaurantRepository.findOne(Long.MIN_VALUE)).thenReturn(restaurant); Restaurant votingRestaurant = new Restaurant(); votingRestaurant.setRestaurantId(Long.MAX_VALUE); Voting outdatedVoting = new Voting(); outdatedVoting.setRestaurant(votingRestaurant); when(votingRepository.findByUser("admin")).thenReturn(outdatedVoting); MvcResult outdatedVoteRes = mockMvc .perform( post("/vote") .contentType(MediaType.APPLICATION_JSON) .content(mapper.writeValueAsString(correctVote))) .andExpect(status().isOk()) .andReturn(); String outdatedVoteResString = outdatedVoteRes.getResponse().getContentAsString(); assertTrue(outdatedVoteResString.contains(Status.FAILED.getStatusValue())); } } catch (Exception e) { fail(); } }
private String timeOfDay() { LocalTime time = LocalTime.now(); String timeOfDay = "ERROR"; if (time.getHour() <= 24 && time.getHour() > 16) { timeOfDay = "evening"; } else if (time.getHour() <= 16 && time.getHour() >= 12) { timeOfDay = "afternoon"; } else if (time.getHour() <= 11) { timeOfDay = "morning"; } return timeOfDay; }
/** Test we schedule to run at a specific date/time */ @Test public void runAt() { Jcl jcl = JclFactory.compileJcl( JOB + "## run at 2016-2-10 18:24\n" + "## run at 2016/2/10 18:24\n" + "## run at 2016-2-10\n" + "## run at 18:24\n" // retry on failure after 1 hour + "## run at 18:24 retry 1 hour\n" + "## run at 18:24 retry 1 hour maximum 3\n" + "## run at 2016/2/10 18:24 retry every 1 hour\n" + "## run at 2016/2/10 18:24 retry every 1 hour maximum 3 times\n"); test(jcl); System.out.println("runat\n" + jcl.getSchedule().replace("><", ">\n<")); assertSame(JclType.SCHEDULABLE, jcl.getType()); String today = LocalDate.now().toString(); String now = LocalTime.now().truncatedTo(ChronoUnit.MINUTES).toString(); assertEquals( "Schedule", "<schedule>" + "<once at=\"2016-02-10 18:24\"/>" + "<once at=\"2016-02-10 18:24\"/>" + "<once at=\"2016-02-10 " + now + "\"/>" + "<once at=\"" + today + " 18:24\"/>" // retry on failure after 1 hour + "<once at=\"" + today + " 18:24\" retry=\"1 hour\"/>" + "<once at=\"" + today + " 18:24\" retry=\"1 hour\" max=\"3\"/>" + "<once at=\"2016-02-10 18:24\" retry=\"1 hour\"/>" + "<once at=\"2016-02-10 18:24\" retry=\"1 hour\" max=\"3\"/>" + "</schedule>", jcl.getSchedule()); }
public static ZonedDateTime getNextSchedule() { ZonedDateTime next_schedule; // Determine type of schedule if (ConfigHandler.backupInterval > 0) // Interval { next_schedule = ZonedDateTime.ofInstant( Instant.ofEpochMilli( System.currentTimeMillis() + (ConfigHandler.backupInterval * 60 * 1000)), ZoneId.systemDefault()); } else // Schedule { if (ConfigHandler.backupSchedule.length == 0) { return null; } LocalTime now = LocalTime.now(); LocalTime next_time = null; LocalDate day = LocalDate.now(); TreeSet<LocalTime> times = new TreeSet<>(); for (String s : ConfigHandler.backupSchedule) { times.add(LocalTime.parse(s, DateTimeFormatter.ofPattern("H:mm"))); } for (LocalTime t : times) // try to find next scheduled time for today { if (t.compareTo(now) == 1) { next_time = t; break; } } if (next_time == null) // if we couldn't find one for today take the first schedule time for tomorrow { day = day.plusDays(1); next_time = times.first(); } next_schedule = ZonedDateTime.of(day, next_time, ZoneId.systemDefault()); } return next_schedule; }
public void addLog(Object object, String other) { if (user.getUsID().equals("test")) return; Log log = new Log(); log.setUser(user); String azione = null; if (object instanceof Offerta) azione = "Lo scout '" + user.getNome() + "' ha inserito l'offerta " + ((Offerta) object).getNome(); else if (object instanceof Pacchetto) { if (other.equals("aggiunto")) azione = "Il designer '" + user.getNome() + "' ha inserito il pacchetto " + ((Pacchetto) object).getNome(); if (other.equals("conferma")) azione = "L'admin '" + user.getNome() + "' ha confermato il pacchetto " + ((Pacchetto) object).getNome(); if (other.equals("rimuovi")) azione = "L'admin '" + user.getNome() + "' ha eliminato il pacchetto " + ((Pacchetto) object).getId(); } else { if (other.equals("login")) azione = user.getRuolo() + " '" + user.getNome() + "' ha effettuato il log in"; if (other.equals("logout")) azione = user.getRuolo() + " '" + user.getNome() + "' ha effettuato il log out"; } log.setAzione(azione); log.setDate(Date.valueOf(LocalDate.now())); log.setTime(Time.valueOf(LocalTime.now())); DAOFactory.getLogDAO().store(log); }
private static void newAPI() { LocalDate soloFecha = LocalDate.now(); LocalTime soloHora = LocalTime.now(); LocalDateTime todo = LocalDateTime.now(); ZonedDateTime zonedDateTime = ZonedDateTime.now(); System.out.println("La fecha " + soloFecha); System.out.println("La hora " + soloHora); System.out.println("La fecha hora " + todo); System.out.println("La fecha hora y zona " + zonedDateTime); LocalDate myFecha = LocalDate.of(2015, Month.JULY, 2); LocalTime myHora = LocalTime.of(9, 21); System.out.println("Ayer fue: " + myFecha); System.out.println("La hora fue: " + myHora); }
@Test public void testTimerWidgetTriggered() throws Exception { Executors.newScheduledThreadPool(1) .scheduleAtFixedRate( new TimerWorker(holder.userDao, holder.sessionDao), 0, 1000, TimeUnit.MILLISECONDS); clientPair.appClient.send("deactivate 1"); verify(clientPair.appClient.responseMock, timeout(500)) .channelRead(any(), eq(new ResponseMessage(1, OK))); Timer timer = new Timer(); timer.id = 1; timer.x = 1; timer.y = 1; timer.pinType = PinType.DIGITAL; timer.pin = 5; timer.startValue = "dw 5 1"; timer.stopValue = "dw 5 0"; LocalTime localDateTime = LocalTime.now(ZoneId.of("UTC")); long curTime = localDateTime.getSecond() + localDateTime.getMinute() * 60 + localDateTime.getHour() * 3600; timer.startTime = curTime + 1; timer.stopTime = curTime + 2; DashBoard dashBoard = new DashBoard(); dashBoard.id = 1; dashBoard.name = "Test"; dashBoard.widgets = new Widget[] {timer}; clientPair.appClient.send("saveDash " + dashBoard.toString()); verify(clientPair.appClient.responseMock, timeout(500)) .channelRead(any(), eq(new ResponseMessage(2, OK))); clientPair.appClient.send("activate 1"); verify(clientPair.appClient.responseMock, timeout(500)) .channelRead(any(), eq(new ResponseMessage(3, OK))); verify(clientPair.hardwareClient.responseMock, timeout(2000)) .channelRead(any(), eq(produce(7777, HARDWARE, "dw 5 1"))); clientPair.hardwareClient.reset(); verify(clientPair.hardwareClient.responseMock, timeout(2000)) .channelRead(any(), eq(produce(7777, HARDWARE, "dw 5 0"))); }
private void removeFromStats(String subType) { if (sessionProvider == null) return; SessionDetails sessionDetails = sessionProvider.get(); if (sessionDetails != null) { String userId = sessionDetails.userId(); Map<String, SubscriptionStat> subStats = getSubscriptionMap(); if (subStats != null) { SubscriptionStat stat = subStats.get(userId + "~" + subType); if (stat == null) { throw new AssertionError("There should be an active subscription"); } stat.setActiveSubscriptions(stat.getActiveSubscriptions() - 1); stat.setRecentlySubscribed(LocalTime.now()); subStats.put(userId + "~" + subType, stat); } } }
/** @author maxrenet */ public class DateExample { static LocalDate one = LocalDate.now(); static LocalDateTime two = LocalDateTime.now(); static LocalTime three = LocalTime.now(); static String dateOne = one.format(DateTimeFormatter.ISO_DATE); static String dateTwo = two.format(DateTimeFormatter.ISO_DATE); static String dateThree = two.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT)); static String dateFour = two.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM)); static String dateFive = two.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG)); // static String timeThree=three.format(DateTimeFormatter.ISO_LOCAL_TIME); public static void main(String[] args) { System.out.println(two); System.out.println("ISODATE returns " + dateTwo); System.out.println("Short date returns " + dateThree); System.out.println("Medium date returns: " + dateFour); System.out.println("Long date returns: " + dateFive); } }
public static void main(String[] args) { LocalDate currentDate = LocalDate.now(); System.out.println(currentDate); LocalDate specificDate = LocalDate.of(2000, 1, 1); System.out.println(specificDate); LocalTime currentTime = LocalTime.now(); System.out.println(currentTime); LocalTime specificTime = LocalTime.of(14, 0, 45); System.out.println(specificTime); LocalDateTime currentDT = LocalDateTime.now(); System.out.println(currentDT); LocalDateTime specificDT = LocalDateTime.of(specificDate, specificTime); System.out.println(specificDT); }
@Override public void initialize(URL location, ResourceBundle resources) { // This controls updating of the clocks final Timeline clockTimeline = new Timeline( new KeyFrame( Duration.seconds(1), e -> { final LocalTime localTime = LocalTime.now(); this.home_clock.setText(localTime.truncatedTo(ChronoUnit.SECONDS).toString()); if ((localTime.getHour() >= 16) & (localTime.getHour() < 17)) { crappyhour = true; } else { crappyhour = false; } })); clockTimeline.setCycleCount(Animation.INDEFINITE); clockTimeline.play(); }
public Order(User user, LocalDate serveAtDate, LocalTime serveAtTime) { createdDate = LocalDate.now(); createdTime = LocalTime.now(); this.user = user; this.serveAtDate = serveAtDate; this.serveAtTime = serveAtTime; orderedMeals = new ArrayList<>(); number = new String(createdDate + "-" + createdTime + "-" + (++user.orderCount)); sspCreatedDate = new SimpleStringProperty(createdDate.toString()); sspCreatedTime = new SimpleStringProperty(createdTime.toString()); sspOrderedMeals = new SimpleStringProperty(); sspUserName = new SimpleStringProperty(user.getUserName().get()); sspNumber = new SimpleStringProperty(number.toString()); sspServeAtDate = new SimpleStringProperty(serveAtDate.toString()); sspServeAtTime = new SimpleStringProperty(serveAtTime.toString()); sspPrice = new SimpleStringProperty(); sspCreatedAtCompact = new SimpleStringProperty(createdDate.toString() + " " + createdTime.toString()); sspServeAtCompact = new SimpleStringProperty(serveAtDate.toString() + " " + serveAtTime.toString()); }
// sparql public void sparql() throws IOException, RepositoryException, QueryEvaluationException { // find all expired data to avoid them participating the query: this.toDeleteCounter = 0; this.dropQueryString = ""; ArrayList<GraphIdCounterPair> expiredData = new ArrayList<GraphIdCounterPair>(); LocalTime evictionTime = LocalTime.now(); for (GraphIdCounterPair x : this.cacheContentOfGraphIds) { System.out.print( this.evictCounter + ", " + this.size + ", " + this.evictAmount + ", " + x.graphId + ", " + x.arrivalTime + ", " + x.expirationTime); if (x.expirationTime.isBefore(evictionTime)) { expiredData.add(x); dropQueryString += "drop graph <" + x.graphId + ">;"; System.out.println(", expired"); ++toDeleteCounter; } else { System.out.println(); } } System.out.println("[INFO] " + expiredData.size() + " data expired!"); if (!expiredData.isEmpty()) { // delete expired data from the cache for (GraphIdCounterPair x : expiredData) { this.cacheContentOfGraphIds.remove(x); } // delete the expired data from the database QueryExecution qe = AGQueryExecutionFactory.create(AGQueryFactory.create(dropQueryString), model); qe.execAsk(); qe.close(); } // after deleting expired data, load the cache again this.streamEmulation(); System.out.println(this.reasoner.getEntailmentRegime()); this.infModel = new AGInfModel(this.reasoner, this.model); String queryString = "select distinct ?s " + "where { ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>" + "<http://swat.cse.lehigh.edu/onto/univ-bench.owl#Professor>.}"; AGRepositoryConnection conn = this.client.getAGConn(); TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString); tupleQuery.setIncludeInferred(true); long sparqlStartTime = System.currentTimeMillis(); TupleQueryResult resultSet = tupleQuery.evaluate(); long sparqlEndTime = System.currentTimeMillis(); this.aveSparql += (sparqlEndTime - sparqlStartTime); ArrayList<String> results = new ArrayList<String>(); while (resultSet.hasNext()) { String result = resultSet.next().toString(); System.out.println("result"); int length = result.length(); results.add(result.substring(3, length - 1)); } resultSet.close(); this.fMeasureBench(results); this.infModel.close(); }