Example usage for java.time.format DateTimeFormatter ISO_LOCAL_TIME

List of usage examples for java.time.format DateTimeFormatter ISO_LOCAL_TIME

Introduction

In this page you can find the example usage for java.time.format DateTimeFormatter ISO_LOCAL_TIME.

Prototype

DateTimeFormatter ISO_LOCAL_TIME

To view the source code for java.time.format DateTimeFormatter ISO_LOCAL_TIME.

Click Source Link

Document

The ISO time formatter that formats or parses a time without an offset, such as '10:15' or '10:15:30'.

Usage

From source file:Main.java

public static void main(String[] args) {
    LocalTime l = LocalTime.parse("12:34", DateTimeFormatter.ISO_LOCAL_TIME);

    System.out.println(l);//from   ww w .java  2s  . com
}

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 w w  . j av a2  s.  c o m
}

From source file:viewmodel.TeamResult.java

public String getTeamTime() {
    LocalTime lt = LocalTime.MIDNIGHT.plus(teamDuration);
    teamTime = DateTimeFormatter.ISO_LOCAL_TIME.format(lt);
    return teamTime;
}

From source file:controllers.TravelControllerTest.java

@Before
public void setUp() throws Exception {
    mockMVC = MockMvcBuilders.standaloneSetup(new TravelController(databaseMock)).build();
    when(userAuthenticationInterceptor.preHandle(any(HttpServletRequest.class), any(HttpServletResponse.class),
            any(Object.class))).thenReturn(Boolean.TRUE);
    user = new User("firstname", "lastname", "password1", "first.last@email.com", true);
    beginDate = LocalTime.parse("10:15:30", DateTimeFormatter.ISO_LOCAL_TIME);
    endDate = LocalTime.parse("12:15:30", DateTimeFormatter.ISO_LOCAL_TIME);
    startPoint = new Address(new Street("teststreet", new City("testcity", "1234", "BE")), 1,
            new Coordinate(50.0, 60.0));
    endPoint = new Address(new Street("teststreet", new City("testcity", "1234", "BE")), 5,
            new Coordinate(55.0, 65.0));
    recurring = new RepetitionWeek();

    recurlist = new ArrayList<>();
    recurlist.add(recurring);/*from ww w. jav  a  2  s  .com*/

    firstTravel = new Travel("travel1", beginDate, endDate, false, startPoint, endPoint, recurlist,
            new HashMap<>(), new ArrayList<>());
    secondTravel = new Travel("travel2", beginDate, endDate, true, endPoint, startPoint, recurlist,
            new HashMap<>(), new ArrayList<>());

    user.addTravel(1, firstTravel);
    user.addTravel(2, secondTravel);

    dto = new TravelDTO();
    dto.setName("dtotravel");
    timeInterval = new String[2];
    timeInterval[0] = "08:15:30";
    timeInterval[1] = "09:15:30";
    dto.setTimeInterval(timeInterval);
    dto.setArrivalTime(false);
    dto.setRecurring(recurring.getAllWeek());
    dto.setStartpoint(new AddressDTO("dtostart", "1", "dtocity", "DC", "1234", new CoordinateDTO(10.0, 20.0)));
    dto.setEndpoint(new AddressDTO("dtoend", "5", "dtocity", "DC", "1234", new CoordinateDTO(15.0, 25.0)));

    when(databaseMock.getUser(anyInt())).thenReturn(user);
}

From source file:net.jmhertlein.alphonseirc.AlphonseBot.java

private void handleDadCommand(final String target, String sender, String[] args) {
    if (args.length == 1) {
        sendMessage(target, "Usage: !dad [left|list|say]");
        return;//  ww w. ja  v a2 s .  c om
    }

    switch (args[1]) {
    case "left":
        ZonedDateTime now = ZonedDateTime.now();
        this.dadLeaveTimes.put(LocalDate.now(), LocalTime.now());
        sendMessage(target,
                "Marked dad's leave time as now (" + now.format(DateTimeFormatter.ISO_LOCAL_TIME) + ").");
        break;
    case "list":
        int num = 3;
        if (args.length == 3) {
            try {
                num = Integer.parseInt(args[2]);
                if (num > 10)
                    num = 10;
            } catch (NumberFormatException nfe) {
                sendMessage(target, "Error parsing " + args[2] + " into int: " + nfe.getMessage());
                sendMessage(target, "Usage: !dad list (optional: number, default 3, max 10)");
                return;
            }
        }

        final int prevDays = num;
        dadLeaveTimes.keySet().stream().sorted()
                .filter(date -> date.isAfter(LocalDate.now().minusDays(prevDays)))
                .map(date -> date.format(DateTimeFormatter.ISO_LOCAL_DATE) + " || "
                        + dadLeaveTimes.get(date).format(DateTimeFormatter.ISO_LOCAL_TIME))
                .forEach(leaveTime -> sendMessage(target, leaveTime));

        break;
    case "say":
        String msg;
        switch (gen.nextInt(9)) {
        case 0:
            msg = "TYPES LOUDLY";
            break;
        case 1:
            msg = "BREATHES DEEPLY";
            break;
        case 2:
            msg = "ANGRILY TYPES AN EMAIL";
            break;
        case 3:
            msg = "BACKSPACES WITH AUTHORITY";
            break;
        case 4:
            msg = "STRETCHES WHILE EXHALING";
            break;
        case 5:
            msg = "thinks about Happy Hour";
            break;
        case 6:
            msg = "browses Yahoo! news";
            break;
        case 7:
            msg = "tells everyone to GET BACK TO WORK";
            break;
        case 8:
            msg = "ignores Lantzer standing in front of his desk";
            break;
        default:
            msg = "Someone made nextInt() go too high";
            break;
        }

        this.sendAction(target, msg);
        break;
    default:
        System.out.println("Bad switch on " + args[1]);
    }

}