
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Samual Sam has Published 2310 Articles

Samual Sam
217 Views
Firstly, let us declare and initialize three long values −long val1 = 98799; long val2 = 98567; long val3 = 98768;Now, find the maximum of three long values using the following condition −// checking for maximum if (val2 > val1) { val1 = val2; } if (val3 ... Read More

Samual Sam
461 Views
To convert String to Long, use the valueOf() method.Let’s say the following is our string.// string String myStr = "5"; System.out.println("String: "+myStr);To convert it to Long, we have used valueOf() −Long longObj = Long.valueOf(myStr);The following is the complete example to convert a String value to Long −Example Live Demopublic class Demo ... Read More

Samual Sam
7K+ Views
The Z means "zero hour offset", also known as "Zulu time" (UTC) in the ISO 8601 time representation. However, ACP 121 standard defines the list of military time zones and derives the "Zulu time" from the Greenwich Mean Time (GMT).TimeZone can be formatted in z, Z or zzzz formats.The following ... Read More

Samual Sam
3K+ Views
To display numbers with leading zeros in Java, useDecimalFormat("000000000000").Let us first set the format with DecimalFormat class −DecimalFormat decFormat = new DecimalFormat("000000000000");Now, let us display some numbers with leading zeros −String res = decFormat.format(298989); System.out.println(res); res = decFormat.format(565); System.out.println(res);The following is an example −Example Live Demoimport java.text.DecimalFormat; public class Demo { ... Read More

Samual Sam
11K+ Views
The format SimpleDateFormat(“HH.mm.ss”) displays time. To work with SimpleDateFormat class, we have imported the following package.import java.text.SimpleDateFormat;Here, we are using the SimpleDateFormat class to display date and time. Let us set it for the format we want i.e time - HH.mm.ss −Format f = new SimpleDateFormat("HH.mm.ss"); String strResult = f.format(new ... Read More

Samual Sam
218 Views
To display a currency in Java, use the following DecimalFormat −DecimalFormat decFormat = new DecimalFormat("\u00a4#, ##0.00");Since, we have used the DecimalFormat class, therefore do not forget to import the following package −import java.text.DecimalFormat;Now, let us learn how to display percentage −decFormat.format(877.80) decFormat.format(8.19) decFormat.format(9897.88)The above will be displayed as −$877.80 $8.19 ... Read More

Samual Sam
229 Views
To display the day number, use the SimpleDateFormat('d') as shown below −Format f = new SimpleDateFormat("d"); String strDay = f.format(new Date()); System.out.println("Day Number = "+strDay);Since, we have used the Format and SimpleDateFormat class above, therefore import the following packages. With that, we have also used the Date −import java.text.Format; import ... Read More

Samual Sam
91 Views
DecimalFormat is a concrete subclass of NumberFormat that formats decimal numbers. Let us set DecimalFormat("##E0") and use the format() method as well.DecimalFormat decFormat = new DecimalFormat("##E0"); System.out.println(decFormat.format(-189.8787)); System.out.println(decFormat.format(8.19)); System.out.println(decFormat.format(9897.88));Since, we have used DecimalFormat class in Java, therefore importing the following package is a must −import java.text.DecimalFormat;The following is the complete ... Read More

Samual Sam
720 Views
To get the column name on the result set, you need to use getMetaData() method. The prototype of getMetadata() is as follows −ResultSetMetaData getMetaData throws SQLException;Create a MySQL table with 5 column names. The query to create a table is as follows −mysql> create table javagetallcolumnnames -> ( ... Read More

Samual Sam
154 Views
Let’s say we need to round number to 3 decimal places, therefore use the following format −DecimalFormat decFormat = new DecimalFormat("0.000");Now, format the number −decFormat.format(37878.8989)Since we have used the DecimalFloat class above, therefore do import the following package −import java.text.DecimalFormat;The following is an example that rounds a number to 3 ... Read More