Notes
Time t1 = Time.newInstance(hour, minute, second, millisecond)
Time t1 = Time.newInstance(2, 12, 45, 12);
System.debug(t1);
DEBUG| 02:12:45.012Z
hour():
returns the hour component of a Time:
Time myTime = Time.newInstance(18, 30, 2, 20);
Integer myHour = myTime.hour();
System.debug(myHour);
DEBUG| 18
minute():
returns the minute component of a Time:
Time myTime = Time.newInstance(18, 30, 2, 20);
Integer myMinute = myTime.minute();
System.debug(myMinute );
DEBUG| 30
second():
returns the second component of a Time:
Time myTime = Time.newInstance(18, 30, 24, 20);
Integer mySecond = myTime.second();
System.debug(mySecond );
DEBUG| 24
milliSecond():
returns the milliSecond component of a Time:
Time myTime = Time.newInstance(18, 30, 2, 320);
Integer myMillisecond = myTime.Millisecond();
System.debug(myMillisecond);
DEBUG| 320
addHours():
adds hours to the hour component of a Time:
Time myTime = Time.newInstance(18, 30, 2, 20);
myTime = myTime.addHours(2);
Integer myHour = myTime.hour();
System.debug(myHour);
DEBUG| 20
addMinutes():
adds minutes to the minute component of a Time:
Time myTime = Time.newInstance(18, 30, 2, 20);
myTime = myTime.addMinutes(20);
Integer myMinute = myTime.minute();
System.debug(myMinute );
DEBUG| 50
addSeconds():
adds seconds to the second component of a Time:
Time myTime = Time.newInstance(18, 30, 20, 400);
myTime = myTime.addSeconds(24);
Integer mySecond = myTime.second();
System.debug(mySecond );
DEBUG| 44
addMilliseconds():
adds milliseconds to the Millisecond component of a Time:
Time myTime = Time.newInstance(18, 30, 20, 400);
myTime = myTime.addMilliseconds(120);
Integer myMilliSecond = myTime.MilliSecond ();
System.debug(myMilliSecond );
DEBUG| 520
YouTube Video Codes
Time t1 =Time.newInstance(12, 35, 52, 000);
System.debug(t1);
System.debug(t1.hour());
System.debug(t1.minute());
System.debug(t1.second());
System.debug(t1.millisecond());
System.debug(t1.addHours(5));
System.debug(t1.addMinutes(12));
System.debug(t1.addSeconds(36));
System.debug(t1.addMilliseconds(500));
Datetime dt1 = Datetime.now();
Date d1 = Date.today();