List of usage examples for java.time LocalTime format
public String format(DateTimeFormatter formatter)
From source file:Main.java
public static void main(String[] args) { LocalTime l = LocalTime.now(); String s = l.format(DateTimeFormatter.ISO_LOCAL_TIME); System.out.println(s);/* w ww . j a va 2 s. co m*/ }
From source file:com.hotelbeds.hotelapimodel.auto.util.AssignUtils.java
public static String getString(final LocalTime time, final DateTimeFormatter formatter) { return time != null ? time.format(formatter) : null; }
From source file:io.manasobi.utils.DateUtils.java
public static String convertToString(LocalTime time, String pattern) { java.time.format.DateTimeFormatter formatter = java.time.format.DateTimeFormatter.ofPattern(pattern); return time.format(formatter); }
From source file:io.manasobi.utils.DateUtils.java
public static String convertToString(LocalTime time) { java.time.format.DateTimeFormatter formatter = java.time.format.DateTimeFormatter .ofPattern(TIME_HMS_PATTERN_COLONE); return time.format(formatter); }
From source file:com.hotelbeds.hotelcontentapi.auto.convert.json.TimeSerializer.java
@Override public void serialize(final LocalTime date, final JsonGenerator generator, final SerializerProvider provider) throws IOException { final String dateString = date.format(REST_FORMATTER); generator.writeString(dateString);// w w w. jav a 2 s .c om }
From source file:com.haulmont.cuba.web.widgets.CubaTimeField.java
protected String formatValue(LocalTime value) { if (value == null) { return ""; }/* ww w . jav a2 s . c o m*/ DateTimeFormatter dateTimeFormatter = getDateTimeFormatter(); return value.format(dateTimeFormatter); }
From source file:de.lgblaumeiser.ptm.analysis.analyzer.HourComputer.java
@Override public Collection<Collection<Object>> analyze(final Collection<String> parameter) { YearMonth requestedMonth = YearMonth.now(); if (parameter.size() > 0) { requestedMonth = YearMonth.parse(Iterables.get(parameter, 0)); }//from ww w .j a v a2s .co m Collection<Collection<Object>> result = Lists.newArrayList(); result.add(Arrays.asList("Work Day", "Starttime", "Endtime", "Presence", "Worktime", "Breaktime", "Overtime", "Comment")); Duration overtime = Duration.ZERO; LocalDate currentday = requestedMonth.atDay(1); while (!currentday.isAfter(requestedMonth.atEndOfMonth())) { Collection<Booking> currentBookings = getBookingsForDay(currentday); if (hasCompleteBookings(currentBookings)) { String day = currentday.format(DateTimeFormatter.ISO_LOCAL_DATE); LocalTime starttime = Iterables.getFirst(currentBookings, null).getStarttime(); LocalTime endtime = Iterables.getLast(currentBookings).getEndtime(); Duration presence = calculatePresence(starttime, endtime); Duration worktime = calculateWorktime(currentBookings); Duration breaktime = calculateBreaktime(presence, worktime); Duration currentOvertime = calculateOvertime(worktime, currentday); overtime = overtime.plus(currentOvertime); result.add(Arrays.asList(day, starttime.format(DateTimeFormatter.ofPattern("HH:mm")), endtime.format(DateTimeFormatter.ofPattern("HH:mm")), formatDuration(presence), formatDuration(worktime), formatDuration(breaktime), formatDuration(overtime), validate(worktime, breaktime))); } currentday = currentday.plusDays(1); } return result; }
From source file:dhbw.clippinggorilla.userinterface.windows.PreferencesWindow.java
private Component getTimeRow(User user, LocalTime time) { HorizontalLayout layoutTimeRow = new HorizontalLayout(); layoutTimeRow.setWidth("100%"); DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedTime(FormatStyle.SHORT); Label labelTime = new Label(time.format(formatter)); Button buttonDelete = new Button(VaadinIcons.TRASH); buttonDelete.addStyleName(ValoTheme.BUTTON_DANGER); buttonDelete.setWidth("80px"); buttonDelete.addClickListener(e -> { if (layoutClippingTimes.getComponentCount() > 1) { layoutClippingTimes.removeComponent(layoutTimeRow); UserUtils.removeClippingSendTime(user, time); } else {/*from www . j a va2 s . c om*/ VaadinUtils.errorNotification(Language.get(Word.AT_LREAST_ONE_TIME)); } }); layoutTimeRow.addComponents(labelTime, buttonDelete); layoutTimeRow.setComponentAlignment(labelTime, Alignment.MIDDLE_LEFT); layoutTimeRow.setComponentAlignment(buttonDelete, Alignment.MIDDLE_CENTER); layoutTimeRow.setExpandRatio(labelTime, 5); return layoutTimeRow; }
From source file:squash.booking.lambdas.core.PageManager.java
private List<String> getTimeSlotLabels() { // First time slot of the day is 10am... // ...so initialise to one time slot (i.e. 45 minutes) earlier logger.log("About to get time slot labels"); LocalTime time = LocalTime.of(9, 15); List<String> timeSlots = new ArrayList<>(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("h:mm a"); for (int slots = 1; slots <= 16; slots++) { time = time.plusMinutes(45);/* w w w.ja v a2 s.c om*/ timeSlots.add(time.format(formatter)); } logger.log("Got slot labels: " + timeSlots); return timeSlots; }
From source file:fll.scheduler.TournamentSchedule.java
/** * Conver the time to a string that will be parsed by {@link #parseTime(String)}. * // w w w. jav a 2 s .co m * @param time the time to format, may be null * @return the formatted time, null converts to "" */ public static String formatTime(final LocalTime time) { if (null == time) { return ""; } else { return time.format(OUTPUT_TIME_FORMAT); } }