monthDay AtYear Method in Java

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

104 Views

The MonthDay can be combined with a year to create a LocalDate using the atYear() method in the MonthDay class in Java. This method requires a single parameter i.e.the year and it returns the LocalDate created by combining MonthDay with the year.A program that demonstrates this is given as follows:Example Live Demoimport java.time.*; public class Demo {    public static void main(String[] args) {       MonthDay md = MonthDay.parse("--02-22");       System.out.println("The MonthDay is: " + md);       LocalDate ld = md.atYear(2019);       System.out.println("The LocalDate is: " + ld);    } }OutputThe MonthDay is: ... Read More

LocalTime plus Method in Java

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

245 Views

An immutable copy of a LocalTime where the required duration is added to it can be obtained using the plus() method in the LocalTime class in Java. This method requires two parameters i.e. the duration to be added and the TemporalUnit of the duration. Also, it returns the LocalTime object with the required duration added to it.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; import java.time.temporal.*; public class Demo {    public static void main(String[] args) {       LocalTime lt = LocalTime.now();       System.out.println("The LocalTime is: " + lt);       ... Read More

Find Items Without a Certain Field in MongoDB

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

189 Views

To find items that do not have a certain field, use the $exists operator. The syntax is as follows −> db.yourCollectionName.find({"yourItemName":{$exists:false}}).pretty();To understand the syntax, let us create a collection with the document. The query to create a collection with a document is as follows −> db.findDocumentDoNotHaveCertainFields.insertOne({"UserId":101, "UserName":"John", "UserAge":21}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8a95fb6cea1f28b7aa07fb") } > db.findDocumentDoNotHaveCertainFields.insertOne({"UserName":"David", "UserAge":22, "UserFavouriteSubject":["C", "Java"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8a96116cea1f28b7aa07fc") } > db.findDocumentDoNotHaveCertainFields.insertOne({"UserName":"Bob", "UserAge":24, "UserFavouriteSubject":["MongoDB", "MySQL"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c8a96306cea1f28b7aa07fd") }Display all documents from a collection with the help of find() method. The ... Read More

Identify Handwritten Digits Using Logistic Regression in PyTorch

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

325 Views

In this we are going to use PyTorch to train a CNN to recognize handwritten digit classifier using the MNIST dataset.MNIST is a widely used dataset for hand-written classification task covering more than 70k labeled 28*28 pixel grayscale images of handwritten digits. The dataset contains almost 60k training images and 10k test images. Our job is to train a model using 60k training images and subsequently test its classification accuracy on 10k test images.InstallationFirst we need the MXNet latest version, for that just run the following on your terminal:$pip install mxnetAnd you will something like, Collecting mxnet Downloading https://files.pythonhosted.org/packages/60/6f/071f9ef51467f9f6cd35d1ad87156a29314033bbf78ad862a338b9eaf2e6/mxnet-1.2.0-py2.py3-none-win32.whl (12.8MB) ... Read More

Scope of Variables in C++

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

388 Views

A scope is a region of the program and broadly speaking there are three places, where variables can be declared −Inside a function or a block which is called local variables, In the definition of function parameters which is called formal parameters.Outside of all functions which is called global variables.We will learn what is a function and it's parameter in subsequent chapters. Here let us explain what are local and global variables.Local VariablesVariables that are declared inside a function or block are local variables. They can be used only by statements that are inside that function or block of code. ... Read More

Select Min and Max Value from Part of a Table in MySQL

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

448 Views

To select min and max value from the part of a table in MySQL, use the following syntax −select min(yourColumnName) as yourAliasName1, max(yourColumnName) as yourAliasName2 from (select yourColumnName from yourTableName limit yourLimitValue) tbl1;Let us first create a table. Following is the query −mysql> create table MinAndMaxValueDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Value int    -> ); Query OK, 0 rows affected (0.52 sec)Insert records in the table using insert command. Following is the query −mysql> insert into MinAndMaxValueDemo(Value) values(10); Query OK, 1 row affected (0.16 sec) mysql> insert into MinAndMaxValueDemo(Value) ... Read More

What Happens to Bitcoin After All 21 Million Coins are Mined

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

167 Views

Bitcoins are created by Satoshi Nakamoto, in 2008 whose identity is still a mystery, whether it is one person or a group of persons. Satoshi Nakamoto proposed Bitcoin as a means of exchange, independent and secure and also a limited number.Now the question comes, Why limited supply?The most important feature of Bitcoin is that it is decentralized. No Central authority will keep a check on its demand or supply. Satoshi has created an open source code which is maintained by a group of volunteer programmers and runs as a distributed network with nodes spread across the world. We know that ... Read More

Convert Date from YYYYMMDD to YY-MM-DD in MySQL Query

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

2K+ Views

To convert date YYYYMMDD to YY-MM-DD in MySQL, use the below syntax −select date_format(str_to_date(yourColumnName, '%Y%m%d'), '%Y-%m-%d') from yourTableName;Let us first create a table −mysql> create table DemoTable (    ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    ClientProjectDeadline varchar(200) ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command. We have inserted dates in the YYYYMMDD format −mysql> insert into DemoTable(ClientProjectDeadline) values('20121221'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable(ClientProjectDeadline) values('20190416'); Query OK, 1 row affected (0.53 sec) mysql> insert into DemoTable(ClientProjectDeadline) values('20160624'); Query OK, 1 row affected (0.20 sec) mysql> ... Read More

Ask Amazon Alexa to Make Playlists for You

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

437 Views

Now you can command "Alexa, Create a new playlist " or "Alexa, add this to my playlist" and Alexa will obey your orders.Here is the know how ...You need Amazon music, as Alexa recognizes only Amazon music.Say "Alexa, create a new playlist" and Alexa will ask you to give the name of the playlist. Name the list. Now your playlist is created and ready.Now you have to add the required songs to the playlists with commands "Alexa, add this song to the playlist".You can even edit a playlist by taking the name of an already existing playlist.As of now deleting a ... Read More

Provider EntrySet Method in Java

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

164 Views

The entries in the Provider have an unmodifiable set view that can be obtained using the method entrySet() in the class java.security.Provider. This method requires no parameters and it returns the unmodifiable set view for the entries in the Provider.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; public class Demo {    public static void main(String[] argv) {       try {          SecureRandom sRandom = SecureRandom.getInstance("SHA1PRNG");          Provider p = sRandom.getProvider();          Set set = p.entrySet();          Iterator i = ... Read More

Advertisements