Karthikeya Boyini has Published 2383 Articles

LocalDate minusDays() Method in Java

karthikeya Boyini

karthikeya Boyini

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

181 Views

An immutable copy of the LocalDate where the days are subtracted from it can be obtained using the minusDays() method in the LocalDate class in Java. This method requires a single parameter i.e. the number of days to be subtracted and it returns the instant with the subtracted days.A program ... Read More

Java Program to convert LocalDateTime to java.util.Date

karthikeya Boyini

karthikeya Boyini

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

378 Views

Set the LocalDateTime to current datetime −LocalDateTime dateTime = LocalDateTime.now();Create an Instant −Instant i = dateTime.atZone(ZoneId.systemDefault()).toInstant(); Convert LocalDateTime to java.util.Date: java.util.Date date = Date.from(i);Example Live Demoimport java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Date; public class Demo {    public static void main(String[] args) {       LocalDateTime dateTime = LocalDateTime.now(); ... Read More

How to check if a table exists in MySQL and create if it does not already exist?

karthikeya Boyini

karthikeya Boyini

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

1K+ Views

If you try to create a table and the table name already exist then MySQL will give a warning message. Let us verify the concept.Here, we are creating a table that already exist −mysql> CREATE TABLE IF NOT EXISTS DemoTable    (    CustomerId int,    CustomerName varchar(30),    CustomerAge ... Read More

Command to check read/write ratio in MySQL?

karthikeya Boyini

karthikeya Boyini

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

524 Views

To check the read/write ratio, you need to use SHOW STATUS command. This will give all the ratios.Case 1 − The syntax is as follows to get the read/write ratio −SHOW STATUS LIKE ‘Com_%’;Case 2 − If you want the insert, update, select and delete ratio, use the below syntax ... Read More

JavaTuples addAtX() method for Triplet class

karthikeya Boyini

karthikeya Boyini

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

58 Views

The addAtX() method is used to add a value to the Triplet Tuple. The index can be set here with the X i.e. the place where the value gets added.Let us first see what we need to work with JavaTuples. To work with Triplet class in JavaTuples, you need to ... Read More

LocalDate minusMonths() Method in Java

karthikeya Boyini

karthikeya Boyini

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

609 Views

An immutable copy of the LocalDate where the months are subtracted from it can be obtained using the minusMonths() method in the LocalDate class in Java. This method requires a single parameter i.e. the number of months to be subtracted and it returns the instant with the subtracted months.A program ... Read More

How to avoid inserting duplicate rows in MySQL?

karthikeya Boyini

karthikeya Boyini

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

411 Views

To avoid inserting duplicate rows in MySQL, you can use UNIQUE(). The syntax is as follows −ALTER TABLE yourTableName ADD UNIQUE(yourColumnName1, yourColumnName2, ...N);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table avoidInsertingDuplicateRows    -> (    -> Id ... Read More

How to sort List in descending order using Comparator in Java

karthikeya Boyini

karthikeya Boyini

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

564 Views

Let us first create an ArrayList −ArrayListarrList = new ArrayList(); arrList.add(10); arrList.add(50); arrList.add(100); arrList.add(150); arrList.add(250);Use Comparators interface to order in reverse order with reverseOrder() −Comparator comparator = Collections.reverseOrder(); Now, sort with Collections: Collections.sort(arrList, comparator);Example Live Demoimport java.util.ArrayList; import java.util.Collections; import java.util.Comparator; public class Demo {    public static void main(String[] args) ... Read More

Create Pair Tuple from List in Java

karthikeya Boyini

karthikeya Boyini

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

736 Views

Use the fromCollection() method to create a Pair Tuple from List collection.Let us first see what we need to work with JavaTuples. To work with Pair class in JavaTuples, you need to import the following package −import org.javatuples.Pair;Note − Steps to download and run JavaTuples program. If you are using ... Read More

How to set result of a java expression in a property in JSP?

karthikeya Boyini

karthikeya Boyini

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

115 Views

The tag is JSTL-friendly version of the setProperty action. The tag is helpful because it evaluates an expression and uses the results to set a value of a JavaBean or a java.util.Map object.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultValueInformation to saveNobodytargetName of the variable whose property should be ... Read More

Advertisements