Karthikeya Boyini has Published 2193 Articles

Java Float isInfinite() Method

karthikeya Boyini

karthikeya Boyini

Updated on 27-Jun-2020 12:57:19

127 Views

The Float.isInfinite() method in Java returns true if this Float value is infinitely large in magnitude, else false is returned.We have the following Float valuesFloat f1 = new Float(5.0/0.0); Float f2 = new Float(10.2/0.0); Float f3 = new Float(0.0/0.0);Check with isInfinite() methodf1.isInfinite(); f2.isInfinite(); f3.isInfinite();The following is the complete example with ... Read More

Java Program to format time with DateFormat.LONG

karthikeya Boyini

karthikeya Boyini

Updated on 27-Jun-2020 12:55:38

239 Views

Use the getTimeInstance() method in Java to get the time format for the locale you have set. DateFormat.LONG is a constant for long style pattern.Firstly, we will create Date objectDate dt = new Date(); DateFormat dateFormat;Let us format time for different locale with DateFormat.LONGdateFormat = DateFormat.getTimeInstance(DateFormat.LONG, Locale.FRENCH); System.out.println("Locale FRENCH = ... Read More

Format Date with getDateTimeInstance() in Java

karthikeya Boyini

karthikeya Boyini

Updated on 27-Jun-2020 12:54:00

550 Views

To format date, let us see the DateFormat.SHORT as well as DateFormat.LONG constants. Both of them displays different patterns.Here, we are formatting dates with getDateTimeInstance() method. Use the method to get a date and time format.For DateFormat.SHORT constant −DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); System.out.println(dateFormat.format(calendar.getTime()));For DateFormat.LONG constant −dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG); ... Read More

Parse string date time value input in Java

karthikeya Boyini

karthikeya Boyini

Updated on 27-Jun-2020 12:44:32

377 Views

In Java, you can parse string date time value input usingSimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z");We have used the above class since we imported the following package −import java.text.SimpleDateFormat;Now, we can display the date in the same format −Date dt = (Date) dateFormatter.parseObject("Tue, 20 Nov 2018 16:10:45 -0530");The following is ... Read More

Display Date Time in dd MMM yyyy hh:mm:ss zzz format in Java

karthikeya Boyini

karthikeya Boyini

Updated on 27-Jun-2020 12:43:18

3K+ Views

Firstly, import the following Java packagesimport java.text.SimpleDateFormat; import java.util.Date;Now, create objectsDate dt = new Date(); SimpleDateFormat dateFormat;Displaying date in the format we want −dateFormat = new SimpleDateFormat("dd MMM yyyy hh:mm:ss zzz");The following is an example −Example Live Demoimport java.text.SimpleDateFormat; import java.util.Date; public class Demo {    public static void main(String args[]) ... Read More

Set a duration in Java

karthikeya Boyini

karthikeya Boyini

Updated on 27-Jun-2020 12:42:06

165 Views

To set a duration, let us declare two objects of Calendar classCalendar c1 = Calendar.getInstance(); Calendar c2 = Calendar.getInstance();Set a time for one of the calendar objectsc2.add(Calendar.HOUR, 9); c2.add(Calendar.MINUTE, 15); c2.add(Calendar.SECOND, 40);Now, find the difference between both the time. One would be the current time and another we declared above ... Read More

Hinge Animation Effect with CSS

karthikeya Boyini

karthikeya Boyini

Updated on 27-Jun-2020 12:39:12

175 Views

To create hinge animation effect with CSS, you can try to run the following code:ExampleLive Demo                    .animated {             background-image: url(/css/images/logo.png);             background-repeat: no-repeat;             ... Read More

Wave effect with CSS?

karthikeya Boyini

karthikeya Boyini

Updated on 27-Jun-2020 12:22:47

2K+ Views

Wave effect is used to give the object a sine wave distortion to make it look wavy.The following parameters can be used in this filter:S.NoParameter & Description1.AddA value of 1 adds the original image to the waved image, 0 does not.2.FreqThe number of waves.3.LightThe strength of the light on the ... Read More

Set a GregorianCalendar object to a particular date in Java

karthikeya Boyini

karthikeya Boyini

Updated on 27-Jun-2020 09:37:21

411 Views

To work with the GregorianCalendar class, import the following package.import java.util.GregorianCalendar;Firstly, create a GregorianCalendar object.GregorianCalendar calendar = new GregorianCalendar();Now, set the above-created object to a date. Here 0 is for 1st month.calendar.set(2018, 0, 25);The following is an example.Example Live Demoimport java.util.GregorianCalendar; import java.util.Calendar; import java.util.Date; public class Demo {    public ... Read More

Modify Date and Time from GregorianCalendar in Java

karthikeya Boyini

karthikeya Boyini

Updated on 27-Jun-2020 09:33:19

829 Views

For GregorianCalendar class, import the following package.import java.util.GregorianCalendar;Firstly, let us display the current date and time.GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance(); System.out.println("Current date: " + cal.getTime());Now, modify the date. Here we are adding two days to the month using the add() method.cal.add((GregorianCalendar.MONTH), 2);Example Live Demoimport java.util.Calendar; import java.util.GregorianCalendar; public class Demo { ... Read More

Advertisements