Android Open Source - SELP2013 Hour Minute






From Project

Back to project page SELP2013.

License

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.

Java Source Code

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);
  }
}




Java Source Code List

uk.co.skywelch.selp2013.AboutActivity.java
uk.co.skywelch.selp2013.CourseInformationActivity.java
uk.co.skywelch.selp2013.CourseListActivity.java
uk.co.skywelch.selp2013.CourseListAdapter.java
uk.co.skywelch.selp2013.Course.java
uk.co.skywelch.selp2013.CoursesParseTask.java
uk.co.skywelch.selp2013.CoursesXmlParser.java
uk.co.skywelch.selp2013.DrawerListAdapter.java
uk.co.skywelch.selp2013.FileDownloader.java
uk.co.skywelch.selp2013.HourMinute.java
uk.co.skywelch.selp2013.Lecture.java
uk.co.skywelch.selp2013.ListItem.java
uk.co.skywelch.selp2013.ListSection.java
uk.co.skywelch.selp2013.StringListItem.java
uk.co.skywelch.selp2013.TimetableActivity.java
uk.co.skywelch.selp2013.TimetableFragment.java
uk.co.skywelch.selp2013.TimetableListAdapter.java
uk.co.skywelch.selp2013.TimetableParseTask.java
uk.co.skywelch.selp2013.TimetableXmlParser.java
uk.co.skywelch.selp2013.VenueInformationActivity.java
uk.co.skywelch.selp2013.Venue.java
uk.co.skywelch.selp2013.VenuesParseTask.java
uk.co.skywelch.selp2013.VenuesXmlParser.java
uk.co.skywelch.selp2013.XMLUtilities.java