Parse time of format hh:mm:ss [closed]

As per Basil Bourque’s comment, this is the updated answer for this question, taking into account the new API of Java 8: String myDateString = “13:24:40”; LocalTime localTime = LocalTime.parse(myDateString, DateTimeFormatter.ofPattern(“HH:mm:ss”)); int hour = localTime.get(ChronoField.CLOCK_HOUR_OF_DAY); int minute = localTime.get(ChronoField.MINUTE_OF_HOUR); int second = localTime.get(ChronoField.SECOND_OF_MINUTE); //prints “hour: 13, minute: 24, second: 40”: System.out.println(String.format(“hour: %d, minute: %d, second: … Read more

How do I parse a URL query parameters, in Javascript? [duplicate]

Today (2.5 years after this answer) you can safely use Array.forEach. As @ricosrealm suggests, decodeURIComponent was used in this function. function getJsonFromUrl(url) { if(!url) url = location.search; var query = url.substr(1); var result = {}; query.split(“&”).forEach(function(part) { var item = part.split(“=”); result[item[0]] = decodeURIComponent(item[1]); }); return result; } actually it’s not that simple, see the … Read more