Java class method

Java class method

I have created a method that's supposed to return a basetime value, returning a string value, the problem is that i need to have it return a basetime to use it later. How can i modify this code to have it returning the basetime value im looking for?
public String plus(BaseTime that) {
int totalSeconds1 = (this.hours * MINUTES_PER_HOUR +
this.minutes) * SECONDS_PER_MINUTE + this.seconds;
int totalSeconds2 = (that.hours * MINUTES_PER_HOUR +
that.minutes) * SECONDS_PER_MINUTE + that.seconds;
int result = totalSeconds1 + totalSeconds2;
int secPlus = result % SECONDS_PER_MINUTE;
int minPlus = (result / SECONDS_PER_MINUTE) % MINUTES_PER_HOUR;
int hourPlus = (result / SECONDS_PER_MINUTE) / MINUTES_PER_HOUR;
String outcome = String.format("%2d:%02d:%02d", hourPlus,
minPlus, secPlus);
return outcome;
}
View Answers









Related Tutorials/Questions & Answers:
class method in java
class method in java  How to write a class method in Java?   You must read Java - Class, Object and Methods in Java
Class and method question, Java?
Class and method question, Java?  Consider a Java class that you could use to get an acceptable integer value from the user. An object of this class.... implement the class in Java c. Write some Java statements that test the class
Advertisements
Java class method - Java Beginners
Java class method  I have created a method that's supposed to return a basetime value, returning a string value, the problem is that i need to have it return a basetime to use it later. How can i modify this code to have
Calling java class method from javascript
Calling java class method from javascript  I want to call a java class method from javascript. The java class method is like "public String[] getWord()". I want to assign this string array value to a variable in javascript. I
Example for a method in java which returns a class
Example for a method in java which returns a class  Hi, I want to create a 1 class,and declare some methods there.I need to method must returns a classname.when i call that particular method(which returns a class),how can i
clone() method of object class - Java Interview Questions
clone method of object class  Why clone() method is defined in Object class.As clone() method is inherited when Clone able Interface is implemented? Please help me in this regard. Thanks in advance
Use of getInt() method of ByteBuffer class in java.
Use of getInt() method of ByteBuffer class in java.  In this tutorial, we will see how to read integer value from byte buffer by using getInt() method of ByteBuffer class. ByteBuffer API: The java.nio.ByteBuffer class extends
Use of hasCode method of FloatBuffer class in java.
Use of hashCode method of FloatBuffer class in java. In this tutorial, we will see the use of hashCode() method of FloatBuffer class in java. FloatBuffer API: The java.nio.FloatBuffer class extends java.nio.Buffer class
Use of hashCode() method of LongBuffer class in java.
Use of hashCode() method of LongBuffer class in java. In this tutorial, we will see the use of hashCode() method of LongBuffer class in java. LongBuffer API: The java.nio.LongBuffer class extends java.nio.Buffer class
Use of getChar method of ByteBuffer Class in java.
Use of getChar method of ByteBuffer Class in java. In this tutorial, we will discuss the use of getChar() method of ByteBuffer class to fetch... of ByteBuffer class write bytes into buffer, and the getChar() method of 
Use of getFloat() method of ByteBuffer class in java.
Use of getFloat() method of ByteBuffer class in java.  In this tutorial...: The java.nio.ByteBuffer class extends java.nio.Buffer class. It provides the following methods:ADS_TO_REPLACE_1 Return type Method
Use of array() method of FloatBuffer class in java.
Use of array() method of FloatBuffer class in java.  In this tutorial, we...: The java.nio.FloatBuffer class extends java.nio.Buffer class. It provides the following methods:ADS_TO_REPLACE_1 Return type Method
Use of getTotalIn and getTotalOut method of Inflater class in java.
Use of getTotalIn and getTotalOut method of Inflater class in java. In this tutorial, we will discuss about getTotalIn() and getTotalOut() method of Inflater... java.lang.Object class. It provid following method: Return Type Method
Use of hasArray() method of ByteBuffer class in java.
Use of hasArray() method of byte buffer class in java. In this tutorial, we... or not, and provides read/write access. ByteBuffer API. The java.nio.ByteBuffer class extends java.nio.Buffer class. It provides the following methods
Use of isDirect() method of intBuffer class in java.
Use of isDirect() method of intBuffer class in java. In this tutorial, we.... The java.nio.IntBuffer class extends java.nio.Buffer class. It provides the following methods: Return type Method Description abstract boolean
Use of isDirect() method of byte buffer class in java.
Use of isDirect() method of ByteBuffer class in java. In this tutorial.... The java.nio.ByteBuffer class extends java.nio.Buffer class. It provides the following methods: Return type Method Description abstract boolean
Use of equals() method of ByteBuffer class in java.
Use of equals() method of ByteBuffer class in java.  In this tutorial, we... or not. ByteBuffer API: The java.nio.ByteBuffer class extends java.nio.Buffer class. It provides the following methods:ADS_TO_REPLACE_1 Return type Method
Use of equals() method of  FloatBuffer class in java.
Use of equals() method of  FloatBuffer class in java.  ... or not. FloatBuffer API: The java.nio.FloatBuffer class extends java.nio.Buffer class. It provides the following methods:ADS_TO_REPLACE_1 Return type
Use of equals() method of IntBuffer class in java.
Use of equals() method of IntBuffer class in java.  In this tutorial, we... or not. IntBuffer API: The java.nioIntBuffer class extends java.nio.Buffer class. It provides the following methods:ADS_TO_REPLACE_1 Return type Method
Use of equals() method of LongBuffer class in java.
Use of equals() method of LongBuffer class in java.  In this tutorial, we... API: The java.nio.LongBuffer class extends java.nio.Buffer class. It provides the following methods:ADS_TO_REPLACE_1 Return type Method
Use of getTotalIn and getTotalOut method of Deflater class in java.
Use of getTotalIn and getTotalOut method of Deflater class in java...; output stream. The finish() method of Deflater class is used to indicate... and getTotalOut() method. The Defleter class create a compressor object
Use of slice method of FloatBuffer class in java.
Use of slice method of FloatBuffer class in java. In this tutorial, we will see the use of slice method of FloatBuffer class in java. FloatBuffer API: The java.nio.FloatBuffer class extends java.nio.Buffer class. It provides
Use of write method of CheckedOutputStream class in java.
Use of write method of CheckedOutputStream class in java. In this tutorial, we will discuss the use of write(int b) method of CheckedOutputStream class... to use write(int b) method of CheckedOutputStream class. The FileInputStream class
ShortBuffer in java, Use of isDirect() method of ShortBuffer class in java.
Use of isDirect() method of ShortBuffer class in java. In this tutorial... API: The java.nio.ShortBuffer class extends java.nio.Buffer class. It provides the following methods:ADS_TO_REPLACE_1 Return type Method
ShortBuffer in java, Use of equals() method of ShortBuffer class in java.
Use of equals() method of ShortBuffer class in java.  In this tutorial... or not. ShortBuffer API: The java.nio.ShortBuffer class extends java.nio.Buffer class... Method Description static ShortBuffer allocate( int capacity
ShortBuffer in java, Use of slice method of ShortBuffer class.
ShortBuffer in java, Use of slice method of ShortBuffer class. In this tutorial, we will see the use of slice method of ShortBuffer class in java. ShortBuffer API: The java.nio.ShortBuffer class extends java.nio.Buffer class
ShortBuffer in java, Use of toString() method of ShortBuffer class.
Use of toString() method of ShortBuffer class. In this tutorial, we will see... API: The java.nio.ShortBuffer class extends java.nio.Buffer class. It provides the following methods:ADS_TO_REPLACE_1 Return type Method
Use of getMethod, getSize and getTime method of ZipEntry class in java.
Use of getMethod, getSize and getTime method of ZipEntry class in java... method of ZipEntry class returns compression method of entry, and the getSize... of ZipEntry class ZipEntry.STORED and ZipEntry.DEFLATED.The entries() method
 Use of getBytesRead, getByteWritten and getRemaining method of Inflater class in java.
Use of getBytesRead, getByteWritten and getRemaining method of Inflater class...() and getRemaining() method of Inflater class. The Inflater class provide...: The java.util.zip.Inflater class extends java.lang.Object class. It provid following method
Abstract class and abstract method
of a concrete class. A single abstract method must exists in a abstract class. A concrete class cannot hold abstract method. An abstract class is meant... be private because it defined in the other class. An abstract methods cannot
Java method Overriding
Java method Overriding       Below example illustrates method Overriding in java. Method overriding in java means a subclass method overriding a super class method. Superclass
javascript call action class method instruts
javascript call action class method instruts  in struts2 onchange event call a method in Actionclass with selected value as parameter how can i do
Use of rewind() method of FloatBuffer class.
Use of rewind() method in float buffer class. In this tutorial, we will see the Use of rewind method of FloatBuffer class. FloatBuffer API: The java.nio.FloatBuffer class extends java.nio.Buffer class. It provides the following
Method Overriding in Java
of Method Overriding in Java : package Overriding; class A { public void call...Method Overriding in Java means a Subclass uses extends keyword to override a super class method. In Overriding both subclass and superclass must have same
Use of putChar() method of ByteBuffer class.
Use of putChar() method of ByteBuffer class.  In this tutorial, we...: The java.nio.ByteBuffer class extends java.nio.Buffer class. It provides the following methods:ADS_TO_REPLACE_1 Return type Method
Use of toString() method of FloatBuffer class.
Use of toString() method of FloatBuffer class. In this tutorial, we will see...: The java.nio.FloatBuffer class extends java.nio.Buffer class. It provides the following methods:ADS_TO_REPLACE_1 Return type Method
Java class in JSP
Java class in JSP          To use a Java class method in jsp first we need... the method defined inside the java class.  ADS_TO_REPLACE_1 The code
Use of hasRemaining() method in float buffer class.
Use of hasRemaining() method in float buffer class. In this tutorial, we will see the use of  hasRemaining method of Buffer class in FloatBuffer. FloatBuffer API: The java.nio.FloatBuffer class extends java.nio.Buffer class
Use of putDouble() and getDouble() method of ByteBuffer class.
Use of putDouble() and getDouble() method of ByteBuffer class.  .... ByteBuffer API: The java.nio.ByteBuffer class extends java.nio.Buffer class. It provides the following methods:ADS_TO_REPLACE_1 Return type
Abstract Class in Java
Abstract class in Java is a class that is declared using abstract keyword..._TO_REPLACE_1 If we have to define an abstract method under class then we have to make... class is extended into subclass, the abstract method of abstract class must
How to call the run method from another class?
How to call the run method from another class?  Sorry, if this is a stupid question. I would like to find out how to call the run method... run() { new FereastraPrincipala().setVisible(true); from the class
Example of skip() method of CheckedInputStream class.
Example of skip() method of CheckedInputStream class. In this tutorial, we will discuss the use of skip() method of CheckedInputStream class. ...() method of CheckedInputStream class. The CheckedInputStream class creates a input
Java call method from another class
Java call method from another class   ...; methods of another class. For this we have created two java files..., multiply, division and modulus have been created inside the class CallingMethod
How to found which class or method contain specific annotation?
How to found which class or method contain specific annotation?  ... categories of testcase. i want to found method or class according to category and execute that method or class which ever is possible
Use of setCrc, setSize and getCrc method of ZipEntry class.
Use of setCrc, setSize and getCrc method of ZipEntry class in java...; getCrc method of ZipEntry class returns crc_32 checksum of uncompressed entry.... The getSize method of ZipEntry class returns uncompressed size of entry data
What’s the difference between accessing a class method via -> and via ::?
What?s the difference between accessing a class method via -> and via ::?  What?s the difference between accessing a class method via -> and via
java method
java method  can we declare a method in java like this static { System.loadLibrary("nativelib"); } i have seen this in a java learning E book. i don't understand the static { } plz help me. what kind of method
Java - Class, Object and Methods in Java
Java - Class, Object and Methods in Java       Class : Whatever we can see in this world all... group. That group is termed as a class. All the objects are direct interacted
JDOM Attribute Example, Different method of Attribute class.
JDOM Attribute Example, Different method of Attribute class...(java.lang.String name) method of Element class returns the child element.The getParent() method of Attribute class returns parent of the associated attribute
Java divide method example
Java divide method example       In this example Java bigdecimal class divide (BigDecimal divisor, MathContext mc) method working is demonstrated. This method divides

Ads