Get Current Time Zone in Android Using Clock API Class

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

1K+ Views

This example demonstrate about How to get current time zone in android using clock API class.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 textview to show current time zone.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.TextView; import java.time.Clock; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {   ... Read More

Duration plusMinutes Method in Java

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

136 Views

An immutable copy of a duration where some minutes are added to it can be obtained using the plusMinutes() method in the Duration class in Java. This method requires a single parameter i.e. the number of minutes to be added and it returns the duration with the added minutes.A program that demonstrates this is given as follows −Example Live Demoimport java.time.Duration; public class Demo {    public static void main(String[] args) {       Duration d = Duration.ofMinutes(5);       System.out.println("The duration is: " + d);       System.out.println("A copy with 3 minutes added to the duration is: ... Read More

Initialization of Multidimensional Arrays in C/C++

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

227 Views

In multidimensional array, the array should have dimension more that 1. The following diagram shows the memory allocation strategy for a multidimensional array with dimension 3 x 3 x 3.This is a C++ program to initialize a multidimensional array.AlgorithmBegin    Initialize the elements of a multidimensional array.    Print the size of the array.    Display the content of the array. EndExample#include using namespace std; int main() {    int r, c;    int a[][2] = {{3,1},{7,6}};    cout

Check Current Configuration of MongoDB

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

2K+ Views

In order to check the current configuration of MongoDB, you can use getCmdLineOpts. The query is as follows −> db._adminCommand( {getCmdLineOpts: 1});The following is the output −{ "argv" : [ "mongod" ], "parsed" : { }, "ok" : 1 }In order to check live settings, you can use the below query −> db._adminCommand({getParameter:"*"});The following is the output &minus{    "AsyncRequestsSenderUseBaton" : true,    "KeysRotationIntervalSec" : 7776000,    "ShardingTaskExecutorPoolHostTimeoutMS" : 300000,    "ShardingTaskExecutorPoolMaxConnecting" : 2,    "ShardingTaskExecutorPoolMaxSize" : -1,    "ShardingTaskExecutorPoolMinSize" : 1,    "ShardingTaskExecutorPoolRefreshRequirementMS" : 60000,    "ShardingTaskExecutorPoolRefreshTimeoutMS" : 20000,    "TransactionRecordMinimumLifetimeMinutes" : 30,    "adaptiveServiceExecutorIdlePctThreshold" : 60,    "adaptiveServiceExecutorMaxQueueLatencyMicros" ... Read More

List All Symbols in a SO File in C++

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

824 Views

To read a .so file in elf format, use readelfreadelf -Ws libName.soIt helps to extract symbol from binary.The standard tool used for listing all symbol is, nmnm -g libName.so

Form a Composite Key to be Unique in MySQL

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

2K+ Views

To form a composite key to be unique, you need to use ADD UNIQUE command. Following is the syntax −alter table yourTableName add unique yourUniqueName( yourColumnName1, yourColumnName2, .......N);Let us first create a table. Following is the query −mysql> create table makeCompositeKeyDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentName varchar(40),    -> StudentAge int,    -> StudentGrade char(1)    -> ); Query OK, 0 rows affected (2.34 sec)Now check the description of the table using DESC command. Following is the query −mysql> desc makeCompositeKeyDemo;This will produce the following output −+--------------+-------------+------+-----+---------+----------------+ | Field   ... Read More

Adjust LocalDate to Next Tuesday Using TemporalAdjusters Class

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

149 Views

At first, set a LocalDate:LocalDate localDate = LocalDate.of(2019, Month.FEBRUARY, 2);Now, adjust the LocalDate to next Tuesday using next() method:LocalDate date = localDate.with(TemporalAdjusters.next(DayOfWeek.TUESDAY));Exampleimport java.time.DayOfWeek; import java.time.LocalDate; import java.time.Month; import java.time.temporal.TemporalAdjusters; public class Demo {    public static void main(String[] args) {       LocalDate localDate = LocalDate.of(2019, Month.FEBRUARY, 2);       System.out.println("Current Date = "+localDate);       System.out.println("Current Month = "+localDate.getMonth());       LocalDate date = localDate.with(TemporalAdjusters.firstDayOfMonth());       System.out.println("First day of month = "+date);       date = localDate.with(TemporalAdjusters.next(DayOfWeek.TUESDAY));       System.out.println("Next Tuesday date = "+date);    } }OutputCurrent Date = 2019-02-02 Current ... Read More

Count Horizontal Values on a MySQL Database

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

459 Views

You can use aggregate function COUNT() from MySQL to count horizontal values on a database. Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    FirstValue int,    SecondValue int,    ThirdValue int,    FourthValue int ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(FirstValue, SecondValue, ThirdValue, FourthValue) values(-18, 45, 0, 155); Query OK,  1 row affected (0.22 sec) mysql> insert into DemoTable(FirstValue, SecondValue, ThirdValue, FourthValue) values(0, 235, null, 15); Query OK,  1 row affected (0.20 sec)Following is the query to display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following ... Read More

FloatBuffer get Method in Java

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

233 Views

The value at the current position of the buffer is read and then incremented using the method get() in the class java.nio.FloatBuffer. This method returns the value that is at the current buffer position. Also, the BufferUnderflowException is thrown if underflow situation occurs.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo {    public static void main(String[] args) {       int n = 5;       try {          FloatBuffer buffer = FloatBuffer.allocate(n);          buffer.put(4.5F);          buffer.put(1.2F);       ... Read More

Make a TXT File in Internal Storage in Android

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

4K+ Views

This example demonstrates How to make a txt file in internal storage 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 editext and button. When the user clicks on the button, it will take data from edit text and store in internal storage as /data/data//files/text/sample.txt.Step 3 − Add the following code to src/MainActivity.javapackage com.example.andy.myapplication; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; ... Read More

Advertisements