Daniol Thomas has Published 242 Answers

MonthDay getMonth() method in Java

Daniol Thomas

Daniol Thomas

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

The month name for a particular MonthDay can be obtained using the getMonth() method in the MonthDay class in Java. This method requires no parameters and it returns the month name in the year.A program that demonstrates this is given as followsExample Live Demoimport java.time.*; public class Demo {    public ... Read More

MonthDay getMonthValue() method in Java

Daniol Thomas

Daniol Thomas

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

The month of the year is obtained using getMonthValue() method in the MonthDay class in Java. This method requires no parameter and it returns the month of the year which may be in the range of 1 to 12.A program that demonstrates this is given as followsExample Live Demoimport java.time.*; public ... Read More

MonthDay getLong() method in Java

Daniol Thomas

Daniol Thomas

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

The long value of a specified Chronofield can be obtained using the getLong() method in the MonthDay class in Java. This method requires a single parameter i.e. the ChronoField and it returns the long value of a specified Chronofield.A program that demonstrates this is given as followsExample Live Demoimport java.util.*; import ... Read More

Period withMonths() method in Java

Daniol Thomas

Daniol Thomas

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

An immutable copy of a Period with the number of months as required is done using the method withMonths() in the Period class in Java. This method requires a single parameter i.e. the number of months in the Period and it returns the Period with the number of months as ... Read More

How to perform custom sort by field value in MySQL?

Daniol Thomas

Daniol Thomas

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

To perform custom sort by field value in MySQL, use the FIELD() method in ORDER BY. Let us first create a table:mysql> create table DemoTable (StudentId int); Query OK, 0 rows affected (0.58 sec)Following is the query to insert some records in the table using insert command:mysql> insert into DemoTable ... Read More

How to create Tab Delimited Select statement in MySQL?

Daniol Thomas

Daniol Thomas

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

To create a tab delimited select statement, you can use CONCAT() function from MySQL. Following is the syntax:select concat(yourColumnName1, "\t", yourColumnName2) AS anyAliasName from yourTableName;Let us first create a table:mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    FirstName varchar(20),    LastName varchar(20) ); Query ... Read More

Selecting a column that is also a keyword in MySQL?

Daniol Thomas

Daniol Thomas

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

To select a column that is also a keyword in MySQL, you need to use backticks around the column name. As you know select is a keyword in MySQL, consider column name as select when creating a new table.Let us create a table:mysql> create table DemoTable (`select` varchar(100)); Query OK, ... Read More

Can we call functions using Callable Statements? Explain with an example in JDBC?

Daniol Thomas

Daniol Thomas

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

Like procedures, you can also create function in a database and store them.SyntaxFollowing is the syntax of creating a function in a(MySQL) database:CREATE FUNCTION Function_Name(input_arguments) RETURNS output_parameter BEGIN    declare variables;    statements . . . . . . . . . .    return data_type;    ENDExampleSuppose we have ... Read More

StringJoiner length() method in Java 8

Daniol Thomas

Daniol Thomas

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

The length() method of the StringJoiner class in Java 8 is used to get the length of the current value of StringJoiner.To work with the StringJoiner in Java 8, import the following package:import java.util.StringJoiner;The syntax is as follows:public int length()First, create a StringJoiner:StringJoiner strJoin = new StringJoiner(", "); strJoin.add("US"); strJoin.add("India"); ... Read More

The size() method of Java AbstractCollection class

Daniol Thomas

Daniol Thomas

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

The size() method of the AbstractCollection class returns the numbers of elements in the collection. The method returns Integer.MAX_VALUE if the total number of elemnts in the collection exceeds the Interger.MAX_VALUE.The syntax is as follows:public abstract int size()To work with AbstractCollection class in Java, import the following package:import java.util.AbstractCollection;The following ... Read More

Advertisements