Samual Sam has Published 2310 Articles

How to set time data type to be only HH:MM in MySQL?

Samual Sam

Samual Sam

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

3K+ Views

You can use DATE_FORMAT() to set time data type to be only HH:MM. Following is the syntax −select DATE_FORMAT(yourColumnName, "%H:%i") AS anyAliasName from yourTableName;Let us first create a table −mysql> create table DemoTable (    Arrivaltime time ); Query OK, 0 rows affected (0.61 sec)Insert records in the table using insert ... Read More

What are JSP literals?

Samual Sam

Samual Sam

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

737 Views

The JSP expression language defines the following literals −Boolean − true and falseInteger − as in JavaFloating point − as in JavaString − with single and double quotes; " is escaped as \", ' is escaped as \', and \ is escaped as \.Null − null

ByteBuffer allocateDirect() method in Java

Samual Sam

Samual Sam

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

338 Views

A direct byte buffer can be allocated using the method allocateDirect() in the class java.nio.ByteBuffer. This method requires a single parameter i.e. the capacity in bytes and it returns the direct byte buffer. If the capacity provided is negative, then the IllegalArgumentException is thrown.A program that demonstrates this is given ... Read More

How to display random numbers less than 20 in Java

Samual Sam

Samual Sam

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

324 Views

At first, create a Random class object −Random rand = new Random();Now, create a new array −int num; int arr[] = new int[10];Loop through and set the Random nextInt with 20 as parameter since you want random numbers less than 20 −for (int j = 0; j

How to convert string to bitset in MySQL?

Samual Sam

Samual Sam

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

269 Views

To convert string to bitset, use the CONV() method. Let us first create a table −mysql> create table DemoTable (    stringValue BIT(4) ); Query OK, 0 rows affected (3.50 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(CONV('1110', 2, 10) * 1); Query OK, ... Read More

ByteBuffer array() method in Java

Samual Sam

Samual Sam

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

641 Views

A byte array for the buffer can be obtained using the method array() in the class java.nio.ByteBuffer. If the returned array is modified, then the contents of the buffer are also similarly modified and vice versa. If the buffer is read-only, then the ReadOnlyBufferException is thrown.A program that demonstrates this ... Read More

How to display numbers in scientific notation in Java?

Samual Sam

Samual Sam

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

5K+ Views

To display number in scientific notation, create NumberFormat object first −NumberFormat numFormat = newDecimalFormat();Now, let’s say you need to format the minimum value of Integer −int i = Integer.MIN_VALUE; System.out.println(i); numFormat = newDecimalFormat("0.######E0"); System.out.println(numFormat.format(i)); numFormat = newDecimalFormat("0.#####E0"); System.out.println(numFormat.format(i));Above, we have used format() method of the NumberFormat class.Example Live Demoimport java.text.DecimalFormat; import ... Read More

How to check whether column value is NULL or having DEFAULT value in MySQL?

Samual Sam

Samual Sam

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

571 Views

You can use the concept of IFNULL() for this. Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Name varchar(100) DEFAULT 'Larry',    Age int DEFAULT NULL ); Query OK, 0 rows affected (0.73 sec)Insert records in the table ... Read More

ByteBuffer asFloatBuffer() method in Java

Samual Sam

Samual Sam

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

166 Views

A view of the ByteBuffer can be created as a FloatBuffer using the asFloatBuffer() method in the class java.nio.ByteBuffer. This method requires no parameters and it returns a float buffer as required. This buffer reflects the changes made to the original buffer and vice versa.A program that demonstrates this is ... Read More

How to write a while loop in a JSP page?

Samual Sam

Samual Sam

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

2K+ Views

Following is the while loop example −           WHILE LOOP Example                           JSP Tutorial                           The above code will generate the following result −JSP Tutorial JSP Tutorial JSP Tutorial

Advertisements