Found 4336 Articles for Java 8

MonthDay get() method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

67 Views

The value of the specified field from the MonthDay can be obtained using the get() method in the MonthDay class in Java. This method requires a single parameter i.e. ChronoField that is required and it returns the value of the specified field from the MonthDay.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; import java.time.temporal.*; public class Demo { public static void main(String[] args) { MonthDay md = MonthDay.parse("--02-22"); System.out.println("The MonthDay is: " + md); System.out.println("The ... Read More

MonthDay query() method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

58 Views

The MonthDay object can be queried as required using the query method in the MonthDay class in Java. This method requires a single parameter i.e. the query to be invoked and it returns the result of the query.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; import java.time.temporal.*; public class Demo { public static void main(String[] args) { MonthDay md = MonthDay.parse("--02-22"); System.out.println("The MonthDay is: " + md); String chronology = md.query(TemporalQueries.chronology()).toString(); ... Read More

MonthDay with() Method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

58 Views

An immutable copy of a MonthDay with the month of the year altered as required is done using the method with() in the MonthDay class in Java. This method requires a single parameter i.e. the month that is to be set in the MonthDay and it returns the MonthDay with the month of the year altered as required.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { MonthDay md1 = MonthDay.parse("--02-22"); System.out.println("The MonthDay ... Read More

MonthDay withMonth() Method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

72 Views

An immutable copy of a MonthDay with the month altered as required is done using the method withMonth() in the MonthDay class in Java. This method requires a single parameter i.e. the month that is to be set in the MonthDay and it returns the MonthDay with the month altered as required.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { MonthDay md1 = MonthDay.parse("--02-22"); System.out.println("The MonthDay is: " + md1); ... Read More

MonthDay toString() Method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

100 Views

The string value of the MonthDay object can be obtained using the method toString() in the MonthDay class in Java. This method requires no parameters and it returns the string value of the MonthDay object.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { MonthDay md = MonthDay.parse("--02-22"); System.out.println("The MonthDay is: " + md.toString()); } }OutputThe MonthDay is: --02-22Now let us understand the above program.The string value of the MonthDay ... Read More

Duration ofMinutes() method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

83 Views

The duration can be obtained in a one minute format using the ofMinutes() method in the Duration class in Java. This method requires a single parameter i.e. the number of minutes and it returns the duration in a one minute format. If the capacity of the duration is exceeded, then the ArithmeticException is thrown.A program that demonstrates this is given as follows −Example Live Demoimport java.time.Duration; public class Demo { public static void main(String[] args) { long minutes = 2; Duration duration = Duration.ofMinutes(minutes); ... Read More

Duration isZero() method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

70 Views

It can be checked if the duration is of zero length or not using the isZero() method in the Duration class in Java. This method requires no parameters. Also, it returns true if the duration is of zero length and false otherwise.A program that demonstrates this is given as follows −Example Live Demoimport java.time.Duration; public class Demo { public static void main(String[] args) { Duration d = Duration.ofHours(1); boolean flag = d.isZero(); System.out.println("The duration is: " + d); ... Read More

Duration isNegative() method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

73 Views

It can be checked if the duration is negative or not using the isNegative() method in the Duration class in Java. This method requires no parameters. Also, it returns true if the duration is negative and false otherwise.A program that demonstrates this is given as follows −Example Live Demoimport java.time.Duration; public class Demo {    public static void main(String[] args) {       Duration d = Duration.ofSeconds(5);       boolean flag = d.isNegative();       System.out.println("The duration is: " + d);       if(flag)          System.out.println("The above duration is negative");       else ... Read More

How to insert rows into a ResultSet in JDBC?

Nancy Den
Updated on 30-Jul-2019 22:30:25

891 Views

You can retrieve the contents of a table as a ResultSet and, insert a new row to it directly. To do so, first of all, you need to make sure your ResultSet is updatable.The moveToInsertRow() method of the ResultSet interface navigates the cursor to the position where you need to insert the next record. Therefore, move the cursor to the appropriate position to insert a row using this method.The updateXXX() methods of the ResultSet interface allows you to insert/update values into the ResultSet object.Add values to the new row using these methods for example if you need to insert an ... Read More

What are batch updates in JDBC? Explain?

Nancy Den
Updated on 30-Jul-2019 22:30:25

888 Views

Grouping a set of INSERT or, UPDATE or, DELETE commands (those produce update count value) and execute them at once this mechanism is known as a batch update.Adding statements to the batchThe statement, PreparedStatement, and CallableStatement objects hold a list (of commands) to which you can add related statements (those return update count value) using the addBatch() method.stmt.addBatch(insert1); stmt.addBatch(insert2); stmt.addBatch(insert3);Executing the batchAfter adding the required statements, you can execute a batch using the executeBatch() method of the Statement interface.stmt.executeBatch();Using batch updates, we can reduce the communication overhead and increase the performance of our Java application.Note: Before adding statements to the ... Read More

Advertisements