Nancy Den has Published 330 Articles

LocalDate until() Method in Java

Nancy Den

Nancy Den

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

99 Views

The difference between two LocalDate objects can be obtained using the until() method in the LocalDate class in Java. This method requires a single parameter i.e. the end date for the LocalDate object and it returns the difference between two LocalDate objects using a Period object.A program that demonstrates this ... Read More

How do you remove an array element by its index in MongoDB

Nancy Den

Nancy Den

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

1K+ Views

To remove array element by its index in MongoDB, you can use $unset and $pull operator. There are two steps to remove array elements from an array.The syntax for the same is as follows:db.yourCollectionName.update({}, {$unset:{"yourArrayListName.yourPosition":yourPositionValue}}; db.yourCollectionName.update({}, {$pull:{"yourArrayListName":null}});To understand the above syntax, let us create a collection with document. The query ... Read More

System Design Using Microcontroller

Nancy Den

Nancy Den

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

1K+ Views

Microprocessors and microcontrollers can be used to design some tools or systems to perform some special tasks. Using microcontrollers, we can make different types of modules or systems. Here is a list of some systems that can be designed by using microcontrollers −Electronic Voting MachineRFID based Access Control SystemHeart Rate ... Read More

How to get the last N records in MongoDB?

Nancy Den

Nancy Den

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

1K+ Views

To get the last N records in MongoDB, you need to use limit(). The syntax is as follows:db.yourCollectionName.find().sort({$natural:-1}).limit(yourValue);To understand the above syntax, let us create a collection with document. The query to create a collection with document is as follows:> db.getLastNRecordsDemo.insertOne({"EmployeeName":"Maxwell"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c6ecf3d6fd07954a4890689") ... Read More

Period plusMonths() method in Java

Nancy Den

Nancy Den

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

99 Views

An immutable copy of the Period object where some months are added to it can be obtained using the plusMonths() method in the Period class in Java. This method requires a single parameter i.e. the number of months to be added and it returns the Period object with the added ... Read More

How to change the type of a field in MongoDB?

Nancy Den

Nancy Den

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

2K+ Views

Let us convert string type to int for an example. Aggregation does not allow us to directly change the type of a field; therefore, you need to write a code to convert the type of a field.At first, create a collection with document. After that we will get the type ... Read More

Group by dates in MongoDB?

Nancy Den

Nancy Den

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

497 Views

You can use aggregate framework to group by dates in MongoDB. Let us first create a collection with some documents. The query to create a collection with documents are as follows:> db.groupByDateDemo.insertOne({"UserLoginDateTime":new ISODate()}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c6ee4df6fd07954a4890695") } > db.groupByDateDemo.insertOne({"UserLoginDateTime":new ISODate("2019-01-31 15:20:09.234Z")}); {    "acknowledged" ... Read More

How can we set time in a table in JDBC?

Nancy Den

Nancy Den

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

225 Views

You can insert time values in SQL using the time datatype, The java.sql.Time class maps to the SQL Time type.The PreparedStatement interface provides a method named setTime(). Using this you can insert time into a table. This method accepts two parameters −An integer representing the parameter index of the place ... Read More

Period plusYears() method in Java

Nancy Den

Nancy Den

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

93 Views

An immutable copy of the Period object where some years are added to it can be obtained using the plusYears() method in the Period class in Java. This method requires a single parameter i.e. the number of years to be added and it returns the Period object with the added ... Read More

Converting string to date in MongoDB?

Nancy Den

Nancy Den

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

884 Views

To convert the string to date in MongoDB, use the following syntax:db.yourCollectionName.aggregate(    [       {          $project:          {             anyVariableName:             {                $dateFromString: ... Read More

Advertisements