The number of years for a particular Period can be obtained using the getYears() method in the Period class in Java. This method requires no parameters and it returns the number of years in the Period.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { String period = "P5Y7M15D"; Period p = Period.parse(period); System.out.println("The Period is: " + p); System.out.println("The number of years are: " + p.getYears()); } }OutputThe Period is: P5Y7M15D The number of ... Read More
At first, let us determine the current delimiter in MySQL using the following syntax\sThe above syntax will let you know about the current delimiter. Let us implement the above syntax.The query is as followsmysql> \sThe following is the outputC:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe Ver 8.0.12 for Win64 on x86_64 (MySQL Community Server - GPL) Connection id: 19 Current database: sample Current user: root@localhost SSL: Cipher in use is DHE-RSA-AES128-GCM-SHA256 Using delimiter: ; Server version: 8.0.12 MySQL Community Server - GPL Protocol version: 10 Connection: localhost via TCP/IP Insert id: 11 Server characterset: utf8 Db characterset: utf8 Client characterset: utf8 Conn. characterset: ... Read More
Before getting into example, we should know what arrayblockingqueue is, it travels FIFO manner and first element going to live longest period of time and last element of the queue going to live short period of the time.This example demonstrate about How to find ArrayBlockingQueue is empty or not in androidStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. In the above code, we have taken text view to showArrayBlockingQueue elements.Step ... Read More
To convert from String to date data type, you need to write some script. Let us first create a collection with documents>db.stringToDateDataTypeDemo.insertOne({"CustomerName":"Carol", "ShippingDate":"2019- 01-21"}); { "acknowledged" : true, "insertedId" : ObjectId("5ca2071d66324ffac2a7dc60") } >db.stringToDateDataTypeDemo.insertOne({"CustomerName":"Bob", "ShippingDate":"2019- 02-24"}); { "acknowledged" : true, "insertedId" : ObjectId("5ca2073566324ffac2a7dc61") } >db.stringToDateDataTypeDemo.insertOne({"CustomerName":"Chris", "ShippingDate":"2019- 04-01"}); { "acknowledged" : true, "insertedId" : ObjectId("5ca2074266324ffac2a7dc62") }Following is the query to display all documents from a collection with the help of find() method> db.stringToDateDataTypeDemo.find().pretty();This will produce the following output{ "_id" : ObjectId("5ca2071d66324ffac2a7dc60"), "CustomerName" : "Carol", "ShippingDate" : "2019-01-21" } { "_id" : ObjectId("5ca2073566324ffac2a7dc61"), ... Read More
To convert string to 24 hour datetime format in MySQL, you can use STR_TO_DATE() method. With that use the following format for datetime as the parameter:'%Y-%m-%d %H:%i:%s'Following is the syntaxSELECT STR_TO_DATE(yourColumnName, '%Y-%m-%d %H:%i:%s') FROM yourTableName;Let us first create a table:mysql> create table DemoTable (ArrivalDate varchar(200)); Query OK, 0 rows affected (0.57 sec)Following is the query to insert some records in the table using insert command:mysql> insert into DemoTable values('2019-01-31 15:45:23'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values('2012-12-12 20:30:26'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values('2016-06-07 21:04:05'); Query OK, 1 row ... Read More
The ConcurrentLinkedQueue class in Java is used to implement a queue using a concurrent linked list. This class implements the Collection interface as well as the AbstractCollection class. It is a part of the Java Collection Framework.A program that demonstrates this is given as follows −Example Live Demoimport java.util.concurrent.*; public class Demo { public static void main(String[] args) { ConcurrentLinkedQueue clQueue = new ConcurrentLinkedQueue(); clQueue.add("Amy"); clQueue.add("John"); clQueue.add("May"); clQueue.add("Harry"); clQueue.add("Anne"); System.out.println("The elements in ConcurrentLinkedQueue are: " + clQueue); } ... Read More
In this program we will see how to subtract two 16-bit numbers with and without borrow.Problem StatementWrite 8086 Assembly language program to subtract two 16-bit number stored in memory location 3000H – 3001H and 3002H – 3003H.Discussion8086 is 16-bit register. We can simply take the numbers from memory to AX and BX register, then subtract them using SUB instruction. When the Borrow is present, the CY flag will be 1, so we can store borrow into memory, otherwise only store AX into memory.InputAddressData……30002D3001FE3002AD3003BC…… Flow Diagram Program OutputAddressData……300480300541300600……
Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to replace whole column in Android sqlite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to ... Read More
Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to use real data type in Android sqliteStep 1 −Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to ... Read More
The if...else block starts out as an ordinary Scriptlet, but the Scriptlet is closed at each line with HTML text included between the Scriptlet tags.Example Live Demo IF...ELSE Example Today is weekend Today is not weekend The above code will generate the following result −Today is not weekend