Back to project page SELP2013.
The source code is released under:
License ======= This work is licensed under the BSD 2-clause license as follows. # BSD 2-clause license Copyright (c) 2013, Sky Welch All rights reserved. Redistribution and use in source and ...
If you think the Android project SELP2013 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package uk.co.skywelch.selp2013; //from w w w . j av a2 s .c o m import java.text.DecimalFormat; public class HourMinute { private int hour; private int minute; public HourMinute(int hour, int minute) { this.hour = hour; this.minute = minute; } // Takes a string in the format hour:minute and initialises the class with it public HourMinute(String time) { hour = -1; minute = -1; if (time == null || time.isEmpty()) { return; } String[] parts = time.split(":"); if (parts.length != 2) { return; } int t_hour = Integer.parseInt(parts[0]); int t_minute = Integer.parseInt(parts[1]); if (t_hour >= 0 && t_hour <= 59) hour = t_hour; if (t_minute >= 0 && t_minute <= 59) minute = t_minute; } public int getHour() { return hour; } public int getMinute() { return minute; } // Returns a string of this class in hour:minute form, two s.f. each (eg 00:00) @Override public String toString() { if (hour == -1 || minute == -1) return "Unknown"; return new DecimalFormat("00").format(hour) + ":" + new DecimalFormat("00").format(minute); } }