Get Beginning of the First Day of This Week from Timestamp in Android SQLite

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

223 Views

Before getting into an example, we should know what SQLite database 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 demonstrates How to get the beginning of the first day of this week from the timestamp in Android SQLite.Step 1 − Create a new project in Android Studio, go to File ... Read More

The contains Method of the Java Key-Value Tuple

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

119 Views

Use the contains() method to search for a value in the KeyValue tuple. Let us first see what we need to work with JavaTuples. To work with KeyValue class in JavaTuples, you need to import the following package.import org.javatuples.KeyValue;Note Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples.Steps: How to run JavaTuples program in EclipseThe following is an example to implement the contains() ... Read More

LocalDateTime equals Method in Java

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

173 Views

The equality of two LocalDateTime objects can be determined using the equals() method in the LocalDateTime class in Java. This method requires a single parameter i.e. the LocalDateTime object to be compared. Also it returns true if both the LocalDateTime objects are equal and false otherwise.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main {    public static void main(String[] args) {       LocalDateTime ldt1 = LocalDateTime.parse("2019-02-18T23:15:30");       LocalDateTime ldt2 = LocalDateTime.parse("2019-02-18T23:15:30");       System.out.println("The LocalDateTime ldt1 is: " + ldt1);       System.out.println("The LocalDateTime ldt2 is: " ... Read More

Add Random Number Between 30 and 300 to Existing Field in MySQL

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

124 Views

Let us first create a demo tablemysql> create table RandomNumberDemo    -> (    -> MyNumber int    -> ); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into RandomNumberDemo values(17); Query OK, 1 row affected (0.20 sec) mysql> insert into RandomNumberDemo values(18); Query OK, 1 row affected (0.12 sec) mysql> insert into RandomNumberDemo values(29); Query OK, 1 row affected (0.49 sec)Display all records from the table using select statement. The query is as follows −mysql> select *from RandomNumberDemo;The following is the output+----------+ | MyNumber | ... Read More

ArrayBlockingQueue put Method in Java

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

122 Views

The put() method of the ArrayBlockingQueue class inserts the specified element at the tail of this queue. It waits for the space to become available, if the queue is full.The syntax is as follows:void put(E e)Here, e is the element to be inserted.To work with ArrayBlockingQueue class, you need to import the following package:import java.util.concurrent.ArrayBlockingQueue;The following is an example to implement put() method of Java ArrayBlockingQueue class:Example Live Demoimport java.util.concurrent.ArrayBlockingQueue; public class Demo {    public static void main(String[] args) throws InterruptedException {       ArrayBlockingQueue q = new ArrayBlockingQueue(7);       q.put(200);       q.put(310);     ... Read More

Junk File Organizer in Python

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

577 Views

This might seem very useful for a lazy python programmer who keeps most of the files and folders at one location and sometimes at confused what all files are there and surely he is too lazy to do it manually. So below is a python program to organize or simplify everything in appropriate folder in the single go and remove empty directories.So we have a directory path where lots of files of different types are present (like below) and our program we segregate each file type into their respective folders (like below).Input folder structureDesired OutputFirst create different folders based on ... Read More

Get Documents by Tags in MongoDB

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

538 Views

You can use $elemMatch operator for this. Let us create a collection with documents> db.getDocumentsByTagsDemo.insertOne({"Tags":["Tag-1", "Tag-2", "Tag-3"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9eb4d5d628fa4220163b79") } > db.getDocumentsByTagsDemo.insertOne({"Tags":["Tag-2", "Tag-4", "Tag-5"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9eb4d5d628fa4220163b7a") } > db.getDocumentsByTagsDemo.insertOne({"Tags":["Tag-6", "Tag-4", "Tag-3"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9eb4d6d628fa4220163b7b") }Following is the query to display all documents from a collection with the help of find() method> db.getDocumentsByTagsDemo.find().pretty();This will produce the following output{    "_id" : ObjectId("5c9eb4d5d628fa4220163b79"),    "Tags" : [       "Tag-1",       "Tag-2",       "Tag-3"    ] } ... Read More

Multiply Columns and Sum Rows with Similar Records Like Customer Name

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

213 Views

To understand this, let us create a table with fields like ID, Customer Name, Items, Price. We will first multiply the items with price. After that the rows with similar records i.e. same customer name will get added.Let us first create a table:mysql> create table DemoTable (    CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    CustomerName varchar(100),    CustomerItems int,    CustomerPrice int ); Query OK, 0 rows affected (0.54 sec)Following is the query to insert some records in the table using insert command:mysql> insert into DemoTable(CustomerName, CustomerItems, CustomerPrice)values('Larry', 3, 450); Query OK, 1 row affected (0.24 sec) mysql> ... Read More

Create Temporary File with Specified Extension Suffix in Java

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

1K+ Views

A temporary file with the specified extension suffix can be created using the method java.io.File.createTempFile(). This method requires two parameters i.e. the prefix to define the file name and the suffix to define the file extension. It also returns the abstract path name for the temporary file created.A program that demonstrates this is given as follows −Example Live Demoimport java.io.File; public class Demo {    public static void main(String[] args) throws Exception {       File file = File.createTempFile("temp", ".java");       System.out.println(file.getAbsolutePath());       file.deleteOnExit();      } }The output of the above program is as follows ... Read More

System Design Using Microcontroller

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

2K+ 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 monitoring systemAutomatic Plant watering systemUltrasonic range finding systemWater level controlling systemGas leakage detection systemFrequency MetersTemperature measuring systemThere are many such systems that can be made by using some microcontrollers.To design a system, we have to follow some basic steps. We have to design the overview of the system, and some ... Read More

Advertisements