Karthikeya Boyini has Published 2383 Articles

How to print current date and time in a JSP page?

karthikeya Boyini

karthikeya Boyini

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

12K+ Views

With JSP program, it is very easy to get the current date and the time. You can use a simple Date object with the toString() method to print the current date and the time as follows −Example Live Demo           Display Current Date & Time   ... Read More

Java Program to create custom DateTime formatter

karthikeya Boyini

karthikeya Boyini

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

141 Views

To create custom DateTime formatter, use DateTimeFormatter. Let us first see for Time −DateTimeFormatter dtFormat = new DateTimeFormatterBuilder() .appendValue(ChronoField.HOUR_OF_DAY) .appendLiteral(":") .appendValue(ChronoField.MINUTE_OF_HOUR) .appendLiteral(":") .appendValue(ChronoField.SECOND_OF_MINUTE) .toFormatter();For Date −dtFormat = new DateTimeFormatterBuilder() .appendValue(ChronoField.YEAR) .appendLiteral("/") .appendValue(ChronoField.MONTH_OF_YEAR) .appendLiteral("/") .appendValue(ChronoField.DAY_OF_MONTH) .toFormatter();Exampleimport java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.temporal.ChronoField; public class Demo {    public static void ... Read More

Finding matching records with LIKE in MongoDB?

karthikeya Boyini

karthikeya Boyini

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

90 Views

Let us first create a collection with documents −> db.likeDemo.insertOne({"Name":"John", Age:32}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb84984623186894665ae41") } > db.likeDemo.insertOne({"Name":"Chris", Age:25}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb84991623186894665ae42") } > db.likeDemo.insertOne({"Name":"Carol", Age:22}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb849a1623186894665ae43") } > db.likeDemo.insertOne({"Name":"Johnny", Age:22}); ... Read More

MySQL command to order timestamp values in ascending order?

karthikeya Boyini

karthikeya Boyini

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

3K+ Views

You can use ORDER BY ASC to order timestamp values in ascending order with TIMESTAMP() method.The following is the syntax using TIMESTAMP() −SELECT timestamp( yourTimestampColumnName ) as anyAliasName From yourTableName order by 1 ASCTo understand the above syntax, let us create a table. The query to create a table is ... Read More

Create Quintet Tuple from another collection in Java

karthikeya Boyini

karthikeya Boyini

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

57 Views

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

Duration isZero() method in Java

karthikeya Boyini

karthikeya Boyini

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

68 Views

It can be checked if the duration is of zero length or not using the isZero() method in the Duration class in Java. This method requires no parameters. Also, it returns true if the duration is of zero length and false otherwise.A program that demonstrates this is given as follows ... Read More

How to insert data into a CachedRowSet in JDBC? Explain?

karthikeya Boyini

karthikeya Boyini

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

497 Views

The CachedRowSet is the base implementation of disconnected row sets. It connects to the data source, reads data from it, disconnects with the data source and the processes the retrieved data, reconnects to the data source and writes the modifications.Creating a CachedRowSetYou can create a Cached RowSet object using the ... Read More

MongoDB query to get specific month|year (not date)?

karthikeya Boyini

karthikeya Boyini

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

594 Views

You can use aggregate framework along with $month projection operator. Let us first create a collection with documents −> db.specificMonthDemo.insertOne({"StudentName":"Larry", "StudentDateOfBirth":new ISODate('1995-01-12')}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb9a9ca8f1d1b97daf71819") } > db.specificMonthDemo.insertOne({"StudentName":"Chris", "StudentDateOfBirth":new ISODate('1999-12-31')}); {    "acknowledged" : true,    "insertedId" : ObjectId("5cb9a9db8f1d1b97daf7181a") } > db.specificMonthDemo.insertOne({"StudentName":"David", "StudentDateOfBirth":new ISODate('2000-06-01')}); ... Read More

Duration equals() method in Java

karthikeya Boyini

karthikeya Boyini

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

231 Views

The equality of two durations can be determined using the equals() method in the Duration class in Java. This method requires a single parameter i.e. the duration to be compared. Also, it returns true if both the durations are equal and false otherwise.A program that demonstrates this is given as ... Read More

Search a value in JavaTuples Septet class

karthikeya Boyini

karthikeya Boyini

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

55 Views

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

Advertisements