Samual Sam has Published 2310 Articles

Duration minusMillis() method in Java

Samual Sam

Samual Sam

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

95 Views

An immutable copy of a duration where some milliseconds are removed from it can be obtained using the minusMillis() method in the Duration class in Java. This method requires a single parameter i.e. the number of milliseconds to be subtracted and it returns the duration with the subtracted milliseconds.A program ... Read More

MySQL where column = 'x, y, z'?

Samual Sam

Samual Sam

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

377 Views

You can use IN operator for this.The syntax is as follows −SELECT *FROM yourTableName WHERE yourColumnName IN(‘yourValue1’, ‘yourValue2’, ‘yourValue3’, ...........N);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table InOperatorDemo    -> (    -> ClientId int   ... Read More

How can I save new Date() in MongoDB?

Samual Sam

Samual Sam

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

154 Views

To save new Date() in MongoDB, you can use new ISODate(). Let us create a collection with documents −> db.saveDateDemo.insertOne({"UserName":"John", "UserLoginDatetime":new ISODate('2018-01-31 12:34:56')}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cbd67d4de8cc557214c0e04") } > db.saveDateDemo.insertOne({"UserName":"John", "UserLoginDatetime":new ISODate('2019-02-01 04:01:10')}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cbd67e8de8cc557214c0e05") } > db.saveDateDemo.insertOne({"UserName":"John", ... Read More

Create Quartet Tuple in Java using with() method

Samual Sam

Samual Sam

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

103 Views

The with() method is also used to create a Quartet tuple in Java.Let us first see what we need to work with JavaTuples. To work with Quartet class in JavaTuples, you need to import the following package −import org.javatuples.Quartet;Note − Steps to download and run JavaTuples program If you are ... Read More

Instant get() method in Java

Samual Sam

Samual Sam

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

225 Views

The value of the required ChronoField for an Instant can be obtained using the get() method in the Instant class in Java. This method requires a single parameter i.e. the ChronoField and it returns the value of the ChronoField that was passed as a parameter.A program that demonstrates this is ... Read More

Java Program to create a Calculator

Samual Sam

Samual Sam

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

2K+ Views

To create a calculator with Java Swings, try the following code −Exampleimport java.awt.Color; import java.awt.Container; import java.awt.FlowLayout; import javax.swing.JFrame; import javax.swing.JLabel; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JTextField; public class SwingDemo extends JFrame implements ActionListener {    JButton one, two, three, four, five, six, seven, eight, nine, num0, ... Read More

Add a temporary column in MySQL where the values depend on another column?

Samual Sam

Samual Sam

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

2K+ Views

You can use CASE statement for this and set conditions to get result in the temporary column.Let us first create a table −mysql> create table DemoTable    (    EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    EmployeeName varchar(20),    EmployeeSalary int,    EmployeeExperience int    ); Query OK, 0 ... Read More

Exact count of all rows in MySQL database?

Samual Sam

Samual Sam

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

420 Views

To exactly count all rows, you need to use the aggregate function COUNT(*). The syntax is as follows −select count(*) as anyAliasName from yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table CountAllRowsDemo    -> (   ... Read More

Duration plusDays() method in Java

Samual Sam

Samual Sam

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

148 Views

An immutable copy of a duration where some days are added to it can be obtained using the plusDays() method in the Duration class in Java. This method requires a single parameter i.e. the number of days to be added and it returns the duration with the added days.A program ... Read More

Using MySQL SELECT for simple BOOLEAN evaluation?

Samual Sam

Samual Sam

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

302 Views

You can use CASE statement for this. Let us see an example −mysql> create table BooleanEvaluationDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> FirstValue int,    -> SecondValue int    -> ); Query OK, 0 rows affected (0.71 sec)Insert some records in the ... Read More

Advertisements