Discover the Quarter of a Given Date in Java

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

2K+ Views

Let us first get the current date −LocalDate currentDate = LocalDate.now();Now, use the Calendar class and set the locale −Calendar cal = Calendar.getInstance(Locale.US);Now, get the month −int month = cal.get(Calendar.MONTH);Find the Quarter −int quarter = (month / 3) + 1;Exampleimport java.time.LocalDate; import java.util.Calendar; import java.util.Locale; public class Demo {    public static void main(String[] args) {       LocalDate currentDate = LocalDate.now();       System.out.println("Current Date = "+currentDate);       Calendar cal = Calendar.getInstance(Locale.US);       int month = cal.get(Calendar.MONTH);       int quarter = (month / 3) + 1;       System.out.println("Quarter = "+quarter);    } }OutputCurrent Date = 2019-04-12 Quarter = 2

Why show dbs Does Not Show My Databases in MongoDB

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

4K+ Views

This SHOW DBS command won’t show the databases because you may have not created a document for a collection. If you will create document for a collection then the created database will be visible.Let us implement the above concept and create a database −> use web; switched to db webFollowing is the query to show all databases −> show dbs;This will produce the following output −admin 0.001GB config 0.000GB local 0.000GB my 0.001GB sample 0.001GB sampleDemo 0.000GB studentSearch 0.000GB test 0.010GB university 0.000GBAbove, the WEB database is not visible since we haven’t created a collection in the same database.In order ... Read More

Change Max Heap Table Size Value in MySQL

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

2K+ Views

The max_heap_table_size is a system variable that has both read/write property.Initially, max_heap_table_size has size 16 MB. First, check the value of max_heap_table_size, which is in bytes.The query is as follows −mysql> select @@max_heap_table_size;The following is the output −+-----------------------+ | @@max_heap_table_size | +-----------------------+ | 16777216 | +-----------------------+ 1 row in set (0.00 sec)Now let us how the value 16777216 byte = 16 MB −1 MB = 1024KB 1KB = 1024 Bytes 1MB = 1024*1024 bytes. To convert 16777216 byte to MB you need to divide 1024*1024. =16777216/(1024*1024) =16777216/1048576 ... Read More

Generation of Triangular Wave Using DAC Interface

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

7K+ Views

We write an 8085 assembly language program for the generation of triangular waveform using the Digital to Analog Converter (DAC) interface. The display of the waveform is seen on the CRO.Let us consider a problem solution in this domain. The problem states that: To get unipolar output, J1 is shorted to J2 on the interface. To display the waveform on a CRO, connect pin 1 of connector P1 to CRO signal pin, and pin 2 of connector P1 to CRO ground pin.Program; FILE NAME DAC_TO_TRIANG.ASM ORG C100H X DW 00FFH ; the fall of rise and time I proportional directly to ... Read More

Add Header Item for ListView in Android

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

3K+ Views

This example demonstrates How to add header item for Listview in Android.Step 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 the name and record number as Edit text, when the user clicks on the save button it will store the data into ArrayList. Click on ... Read More

Does SELECT TOP Command Exist in MySQL?

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

239 Views

There is no concept of TOP in MySQL. The alternate way to write your query is using LIMIT i.e to select 2 records, you need to use TOP 2. Let us see the syntax for the same in MySQLSELECT *FROM yourTableName ORDER BY yourColumnName DESC LIMIT 2;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table Top2Demo    - > (    - > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    - > Name varchar(20),    - > Age int    - > ); Query OK, 0 rows ... Read More

Parse JSON String in Android

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

1K+ Views

This example demonstrates How to parse JSON string in android.Step 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 a text view to show the json element name.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.app.KeyguardManager; import android.app.admin.DevicePolicyManager; import android.content.Context; import android.net.ConnectivityManager; import android.net.Network; import android.net.NetworkInfo; import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.view.KeyEvent; import android.widget.TextView; import ... Read More

IntStream of Method in Java

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

477 Views

The IntStream class in Java the following two forms of of() methodIntStream of(int t) methodThe following of() method returns a sequential IntStream containing a single element. Here is the syntaxstatic IntStream of(int t)Here, parameter t is the single element.IntStream of(int… values) methodThe following of() method returns a sequentially ordered stream whose elements are the specified valuesstatic IntStream of(int… values)Here, the parameter values are the elements of the new stream.The following is an example to implement IntStream of() method in JavaExample Live Demoimport java.util.*; import java.util.stream.IntStream; public class Demo {    public static void main(String[] args) {       IntStream intStream ... Read More

Collectors maxBy Method in Java 8

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

2K+ Views

The maxBy() method of the Collectors class in Java 8 returns a Collector that produces the maximal element according to a given Comparator, described as an Optional.The syntax is as followsstatic Collector maxBy(Comparator

Pass By Value vs Pass By Reference in C++

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

555 Views

In C++ we can pass arguments into a function in different ways. These different ways are −Call by ValueCall by ReferenceCall by AddressSometimes the call by address is referred to as call by reference, but they are different in C++. Incall by address, we use pointer variables to send the exact memory address, but in call by reference we pass the reference variable (alias of that variable). This feature is not present in C, there we have to pass the pointer to get that effect.In this section, we will see what are the advantages of call by reference over call ... Read More

Advertisements