Get Java Home Directory

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

1K+ Views

Use the System.getProperty() method in Java to get the Java Home Directory.It’s syntax is −String getProperty(String key)Above, the key is the name of the system property. Since, we want the Java Home Directory name, therefore we will add the key as −java.homeThe following is an example −Example Live Demopublic class Demo { public static void main(String[] args) { System.out.println("Get Java Home Directory = " + System.getProperty("java.home")); System.out.print("Java Specification Version: "); System.out.println(System.getProperty("java.specification.version")); System.out.print("java Runtime Environment ... Read More

Get Localized Short Day Name in Java

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

332 Views

Use the ‘a’ date conversion character to display short day-in-week.System.out.printf("Localized short day name = %ta/%Ta", d, d);Above, d is a date object −Date d = new Date();The following is an example −Example Live Demoimport java.util.Date; import java.text.DateFormat; import java.text.SimpleDateFormat; public class Demo { public static void main(String[] args) throws Exception { Date d = new Date(); DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss a"); String format = dateFormat.format(d); System.out.println("Current date and time = " + ... Read More

Is BIGINT(8) the Largest Integer MySQL Can Store?

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

3K+ Views

In BIGINT(8), the number 8 represents how the data will be displayed. It does not affect the storage. The number is used to display width.BIGINT takes 8 bytes i.e. 64 bits. The signed range is -9223372036854775808 to 9223372036854775807 and unsigned range takes positive value. The range of unsigned is 0 to 18446744073709551615.To understand bigint(8), let us create a table with BIGINT(8) and zerofill column −mysql> create table BigIntDemo8 -> ( -> Number1 BIGINT(8) not null, -> Number2 BIGINT(8) unsigned zerofill not null -> ); Query OK, 0 rows ... Read More

Find Number of Days in a Month in MySQL

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

5K+ Views

To find the number of days in month, use the below syntax.select DAY(LAST_DAY(yourColumnName)) as anyVariableName from yourTableName;To understand the above syntax, let us first create a table. The query to create a table is as follows.mysql> create table DaysInaGivenMonth -> ( -> MonthName datetime -> ); Query OK, 0 rows affected (1.62 sec)Insert some records in the table using insert command. The query is as follows.mysql> insert into DaysInaGivenMonth values(now()); Query OK, 1 row affected (0.24 sec) mysql> insert into DaysInaGivenMonth values(date_add(now(), interval -1 month)); Query OK, 1 row affected (0.16 sec) mysql> insert into DaysInaGivenMonth values(date_add(now(), interval ... Read More

Disable Landscape Mode in Android

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

2K+ Views

Android supports two orientations as portrait and landscape. we can disable orientation in android application. This example demonstrate about how to disable landscape mode 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, it contains linear layout and editext. it going to support both landscape and portrait as shown below -The above output indicates about landscape modeThe above output indicates about portrait mode.To disable landscape mode need ... Read More

Why Don't We Create Green Top Pitches in India

Diler Singh
Updated on 30-Jul-2019 22:30:24

422 Views

India-West Indies Test Series is starting from today and so is the debate over green-tops. Undoubtedly, India is a very strong side and have the ability to beat any ferocious opponent on the ground, especially when they play on their home grounds, in India, and in favorable conditions. Similarly, we all know how these home tigers suffer when they land out of the subcontinent. They crash every record of the poor game and impetrate to win a single match out of a series of five.This is what we witnessed in England recently. Not only this time but every time we ... Read More

MySQL Update Query to Remove Spaces Between Letters

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

3K+ Views

If you have spaces between letters then you can use REPLACE() function to remove spaces.The syntax is as follows −UPDATE yourTableName SET yourColumnName=REPLACE(yourColumnName, ’ ‘, ’’);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table removeSpaceDemo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> UserId varchar(20), -> UserName varchar(10), -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.81 sec)Now insert some records in the table using insert ... Read More

Return Date Set to Last Millisecond of Month Before Midnight in Java

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

337 Views

Use the getMaximum() method in Java to returns the maximum value for the given calendar field. We will use it to set the minute, second and millisecond.Let us first declare a calendar object −Calendar dateNoon = Calendar.getInstance();Now, we will set the hour, minute, second and millisecond to the last possible millisecond on the month before midnight.// hour, minute and second calendar.set(Calendar.HOUR_OF_DAY, calendar.getMaximum(Calendar.HOUR_OF_DAY)); calendar.set(Calendar.MINUTE, calendar.getMaximum(Calendar.MINUTE)); calendar.set(Calendar.SECOND, calendar.getMaximum(Calendar.SECOND)); // millisecond calendar.set(Calendar.MILLISECOND, calendar.getMaximum(Calendar.MILLISECOND));Now, do the following for month and day of month −calendar.set(Calendar.DAY_OF_MONTH, 1); // first day of month calendar.add(Calendar.MONTH, 1); calendar.add(Calendar.DAY_OF_MONTH, -1);The following is an example to return a Date set to ... Read More

Convert INT to DATETIME in MySQL

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

3K+ Views

You can use the in-built function from_unixtime() to convert INT to DATETIME. The syntax is as follows −SELECT FROM_UNIXTIME(yourColumnName, ’%Y-%m-%d') as AnyVariableName from yourTableName;To understand the above syntax, let us first create a table. The query to create a table is as follows −mysql> create table IntToDateDemo -> ( -> Number int -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command. The query to insert record is as follows −mysql> truncate table IntToDateDemo; Query OK, 0 rows affected (4.11 sec) mysql> insert ... Read More

Find 1's and 2's Complement of 16-bit Number in 8085

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:24

3K+ Views

In this program we will see how to find 1's complement and 2's complement of a 16-bit number.Problem StatementWrite 8085 Assembly language program to find 1's complement and 2's complement of a16-bit number stored in 8000H and 8001H.Discussion8085 has an instruction CMA. This instruction complements the content of Accumulator. For 1's complement CMA instruction is sufficient, and for 2's complement we have to increase the number by 1 after complementing.For 16-bit number, we are taking the number into HL pair, but for complementing we have to copy the numbers to Accumulator from H and L one by one. Then by ... Read More

Advertisements