Esempio n. 1
0
        //Accepts String to convert Simple Input Format hh:mm:ss to Time Object, Throws Application Exception for wrong format
        public Time SetInput(String time)
        {
            string[] timeValues = time.Split(new string[] { ":" }, StringSplitOptions.None);
            Time     t          = new Time();

            t.setHours(Int32.Parse(timeValues[0]));
            t.setMinutes(Int32.Parse(timeValues[1]));
            t.setSeconds(Int32.Parse(timeValues[2]));
            return(t);
        }
Esempio n. 2
0
        //Split the time to hours,minutes and Seconds
        private Time SetTime(String sTime)
        {
            Time time = new Time();

            string[] timeValues = sTime.Split(new string[] { ":" }, StringSplitOptions.None);

            time.setHours(Int32.Parse(timeValues[0]));
            time.setMinutes(Int32.Parse(timeValues[1]));
            time.setSeconds(Int32.Parse(timeValues[2]));

            return(time);
        }
Esempio n. 3
0
 public static Time convertFromString(string aTime)
 {
     try
     {
         var time         = new Time();
         var splittedTime = aTime.Split(':');
         time.setSeconds(int.Parse(splittedTime[2]));
         time.setMinutes(int.Parse(splittedTime[1]));
         time.setHours(int.Parse(splittedTime[0]));
         return(time);
     }
     catch (Exception ex)
     {
         throw new InvalidFormatException(String.Format("Please enter a valid time. Exception: {0}", ex.Message));
     }
 }