Samual Sam has Published 2310 Articles

LocalDateTime hashCode() method in Java

Samual Sam

Samual Sam

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

169 Views

The hash code value of the LocalDateTime can be obtained using the hashCode() method in the LocalDateTime class in Java. This method requires no parameters and it returns the hash code value of the LocalDateTime.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { ... Read More

Clock system() Method in Java

Samual Sam

Samual Sam

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

275 Views

The current instance of the clock for the required zoneID can be obtained using the method system() in Clock Class in Java. This method requires a single parameter i.e. the zoneID or the time zone and it returns the current instance of the clock for that time zone.A program that ... Read More

Extracting filenames from a path in MySQL?

Samual Sam

Samual Sam

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

665 Views

To extract filenames from a path MySQL, you can use SUBSTRING_INDEX(). The syntax is as follows −SELECT SUBSTRING_INDEX(ypurColumnName, '\', -1) 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 ExtractFileNameDemo -> ... Read More

ShortBuffer duplicate() method in Java

Samual Sam

Samual Sam

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

98 Views

A duplicate buffer of a buffer can be created using the method duplicate() in the class java.nio.ShortBuffer. This duplicate buffer is identical to the original buffer. The method duplicate() returns the duplicate buffer that was created.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public ... Read More

The contains() method of Java Unit Tuple

Samual Sam

Samual Sam

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

182 Views

To search a value in Unit class in JavaTuples, use the contains() method.Let us first see what we need to work with JavaTuples. To work with the Unit class in JavaTuples, you need to import the following package −import org.javatuples.Unit;Note − Steps to download and run JavaTuples program If you ... Read More

Java Program to get timezone id strings

Samual Sam

Samual Sam

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

225 Views

Let us get the timezone id strings for timezone America. For this, use the get.AvailableZoneIds() method −ZoneId.getAvailableZoneIds().stream().filter(s ->s.startsWith("America")) .forEach(System.out::println);With that, we have used the forEach to display all the timezones in America −America/Cuiaba America/Marigot America/El_Salvador America/Guatemala America/Belize America/Panama America/Managua America/Indiana/Petersburg America/Chicago America/Tegucigalpa America/Eirunepe America/Miquelon . . .Exampleimport java.time.ZoneId; public class ... Read More

ShortBuffer compareTo() method in Java

Samual Sam

Samual Sam

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

109 Views

A buffer can be compared with another buffer using the method compareTo() in the class java.nio.ShortBuffer. This method returns a negative integer if the buffer is less than the given buffer, zero if the buffer is equal to the given buffer and a positive integer if the buffer is greater ... Read More

What is a Pair class in Java Tuples?

Samual Sam

Samual Sam

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

194 Views

A Pair class in JavaTuples can only have 2 elements. The JavaTuples library includes the Pair class.The following is the declaration −public final class Pair extends Tuple implements IValue0, IValue1Let us first see what we need to work with JavaTuples. To work with Pair class in JavaTuples, you need to ... Read More

Perform search/replace for only the first occurrence of a character in MySQL table records?

Samual Sam

Samual Sam

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

3K+ Views

You can achieve this with the help of CONCAT() along with REPLACE() function. To find the first occurrences you need to use INSTR() function.The syntax is as follows −UPDATE yourTableName SET UserPost = CONCAT(REPLACE(LEFT(yourColumnName, INSTR(yourColumnName, 'k')), 'k', 'i'), SUBSTRING(yourColumnName, INSTR(yourColumnName, 'k') + 1));To understand the above syntax, let us create ... Read More

Return a specific field in MongoDB?

Samual Sam

Samual Sam

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

376 Views

Too return a specific field, use the find() method in MongoDB. Let us first create a collection with documents −> db.specificFieldDemo.insertOne({"FirstName":"John", "LastName":"Doe"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb8019a623186894665ae31") } > db.specificFieldDemo.insertOne({"FirstName":"John", "LastName":"Smith"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb801ab623186894665ae32") } > db.specificFieldDemo.insertOne({"FirstName":"David", "LastName":"Miller"}); {   ... Read More

Advertisements