Samual Sam has Published 2310 Articles

Display time zone with SimpleDateFormat(“z”) in Java

Samual Sam

Samual Sam

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

2K+ Views

You can display timezone easily in Java using SimpleDateFormat(“z”).Firstly, to work with SimpleDateFormat class in Java, import the following package −import java.text.SimpleDateFormat;Now, set the format with SimpleDateFormat(“z”) to display timezone −Format f = new SimpleDateFormat(”z”);Now, get the timezone in a string −String strTimeZone = f.format(new Date());The following is an example ... Read More

ftp_systype() function in PHP

Samual Sam

Samual Sam

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

87 Views

The ftp_systype() function returns the system type identifier of the FTP server.Syntaxftp_systype(con);Parameterscon − The FTP connectionReturnThe ftp_systype() function returns the system type on success, or FALSE on failure.ExampleThe following is an example −

Java Program to subtract long integers and check for overflow

Samual Sam

Samual Sam

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

787 Views

To check for Long overflow, we need to check the Long.MAX_VALUE with the subtracted long result. Here, Long.MAX_VALUE is the maximum value of Long type in Java.Let us see an example wherein long integers are subtracted and if the result is still more than the Long.MAX_VALUE, then an exception is ... Read More

Convert long primitive to Long object in Java

Samual Sam

Samual Sam

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

9K+ Views

To convert long primitive to Long object, follow the below steps.Let’s say the following is our long primitive.// primitive long val = 45; System.out.println("long primitive: "+val);Now, to convert it to Long object is not a tiresome task. Include the same long value while creating a new Long object −// object ... Read More

ezmlm_hash() function in PHP

Samual Sam

Samual Sam

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

132 Views

The ezmlm_hash() function calculates the hash value needed when keeping EZMLM mailing lists in a MySQL database.Syntaxezmlm_hash(addr);Parametersaddr − The email address being hashed.ReturnThe ezmlm_hash() function returns the hash value of addr.ExampleThe following is an example −

Java Program to divide one BigDecimal from another BigDecimal

Samual Sam

Samual Sam

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

172 Views

Use the divide method to divide one BigDecimal to another in Java. The method returns a BigDecimal whose value is (this / divisor), and whose preferred scale is (this.scale() - divisor.scale()).If the exact quotient cannot be represented (because it has a non-terminating decimal expansion) an ArithmeticException is thrown.The following is ... Read More

Display hour in KK (00-11) format in Java

Samual Sam

Samual Sam

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

220 Views

The “KK” format in Java Date is used to display hour in 00-11.. Use SimpleDateFormat("KK") to get the same format −// displaying hour in KK format SimpleDateFormat simpleformat = new SimpleDateFormat("KK"); String strHour = simpleformat.format(new Date()); System.out.println("Hour in KK format = "+strHour);Above, we have used the SimpleDateFormat class, therefore the ... Read More

Set Decimal Place of a Big Decimal Value in Java

Samual Sam

Samual Sam

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

5K+ Views

We have the following BigDecimal value −BigDecimal val1 = new BigDecimal("37578975587.876876989");We have set the decimal place to be −int decPlaces1 = 3;Now, we will use the ROUND_DOWN field to set the rounding mode to round towards zero −// ROUND_DOWN val1 = val1.setScale(decPlaces1, BigDecimal.ROUND_DOWN); String str1 = val1.toString(); System.out.println("Result = "+str1);To ... Read More

connection_status() function in PHP

Samual Sam

Samual Sam

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

169 Views

The connection_status() function returns the connection status.Syntaxconnection_status()ParametersNAReturnThe connection_status() function returns the following possible values. This is the status bitfield −0 - CONNECTION_NORMAL - connection is running normally1 - CONNECTION_ABORTED - connection is aborted by user or network error2 - CONNECTION_TIMEOUT - connection timed out3 - CONNECTION_ABORTED & CONNECTION_TIMEOUTExampleThe following is ... Read More

Math operations for BigDecimal in Java

Samual Sam

Samual Sam

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

5K+ Views

Let us apply the following operations on BigDecimal using the in-built methods in Java −Addition: add() method Subtraction: subtract() method Multiplication: multiply() method Division: divide() methodLet us create three BigInteger objects −BigDecimal val1 = new BigDecimal("37578975587.876876989"); BigDecimal val2 = new BigDecimal("62567875598.976876569"); BigDecimal val3 = new BigDecimal("72567875598.376876569");Apply mathematical operations on them ... Read More

Advertisements