Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Separates the hour segment from a date string and converts and returns it as an int.
     * The hour string must be the last segment, preceded by a colon, eg: dd.MM.yyyy:HH.
     *
     * @param date The string representation of the date.
     * @return The hour segment in int form.
     */
    public static int getHourFromDate(String date) {
        return Integer.parseInt(date.split(":")[1]);
    }
}