Java Articles

Page 49 of 450

How to print date and time in specific format using JSP?

Samual Sam
Samual Sam
Updated on 11-Mar-2026 2K+ Views

SimpleDateFormat is a concrete class for formatting and parsing dates in a locale-sensitive manner. SimpleDateFormat allows you to start by choosing any user-defined patterns for date-time formatting.Let us modify the above example as follows −Example           Display Current Date & Time                        Display Current Date & Time                 Compile the above servlet once again and then call this servlet using the URL http://localhost:8080/CurrentDate. You will receive the following result −OutputDisplay Current Date & Time Mon 2010.06.21 at 10:06:44 PM GMT+04:00

Read More

Duration ZERO field in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 669 Views

The ZERO field sets the duration to zero in the Duration class in Java. This field is quite the same as the null value in different data types in Java.A program that demonstrates the ZERO field is given as follows −Exampleimport java.time.Duration; public class Demo {    public static void main(String[] args) {       Duration d = Duration.ZERO;       boolean flag = d.isZero();       System.out.println("The duration is: " + d);       if(flag)          System.out.println("The above duration is of zero length");       else          System.out.println("The ...

Read More

Instant isSupported() method in Java

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 191 Views

It can be checked if a ChronoUnit is supported by the Instant class or not by using the isSupported() method in the Instant class in Java. This method requires a single parameter i.e. the ChronoUnit to check. It returns true if the ChronoUnit is supported by the Instant class and false otherwise.A program that demonstrates this is given as follows −Exampleimport java.time.*; import java.time.temporal.ChronoUnit; public class Demo {    public static void main(String[] args) {       Instant i = Instant.now();       System.out.println("The current instant is: " + i);       boolean flag = i.isSupported(ChronoUnit.SECONDS);   ...

Read More

Instant range() method in Java

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 785 Views

The range of values for a field can be obtained using the range() method in the Instant class in Java. This method requires a single parameter i.e. the ChronoField for which the range of values are required and it returns the range of valid values for the ChronoField.A program that demonstrates this is given as follows −Exampleimport java.time.*; import java.time.temporal.ChronoField; import java.time.temporal.ValueRange; public class Demo { public static void main(String[] args) { Instant i = Instant.now(); ValueRange range1 = i.range(ChronoField.MILLI_OF_SECOND); ...

Read More

Instant get() method in Java

Samual Sam
Samual Sam
Updated on 11-Mar-2026 274 Views

The value of the required ChronoField for an Instant can be obtained using the get() method in the Instant class in Java. This method requires a single parameter i.e. the ChronoField and it returns the value of the ChronoField that was passed as a parameter.A program that demonstrates this is given as follows −Exampleimport java.time.*; import java.time.temporal.ChronoField; import java.time.temporal.ValueRange; public class Demo {    public static void main(String[] args) {       Instant i = Instant.now();       int micro = i.get(ChronoField.MICRO_OF_SECOND);       System.out.println("The current Instant is: " + i);       System.out.println("The MICRO_OF_SECOND Field ...

Read More

IntStream peek() method in Java

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 773 Views

The peek() method in the IntStream class in Java returns a stream consisting of the elements of this stream. It additionally performs the provided action on each element as elements are consumed from the resulting stream.The syntax is as followsIntStream peek(IntConsumer action)Here, the parameter action is a non-interfering action to perform on the elements as they are consumed from the stream. The IntConsumer represents an operation that accepts a single int-valued argument and returns no result.The following is an example to implement IntStream peek() method in JavaExampleimport java.util.*; import java.util.stream.IntStream; public class Demo { public static void ...

Read More

The contains() method of AbstractSequentialList in Java

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 172 Views

The contains() method of AbstractSequentialList in Java is used to check whether an element is in the Collection.The syntax is as followspublic boolean contains(Object ob)Here, ob is the element to be checked. To work with the AbstractSequentialList class in Java, you need to import the following packageimport java.util.AbstractSequentialList;The following is an example to implement AbstractSequentialList contains() method in JavaExampleimport java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo { public static void main(String[] args) { AbstractSequentialList absSequential = new LinkedList(); absSequential.add(250); absSequential.add(320); ...

Read More

IntStream forEachOrdered() method in Java

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 439 Views

The forEachOrdered() method in Java assures that each element is processed in order for streams that have a defined encounter order.The syntax is as followsvoid forEachOrdered(IntConsumer action)Here, the action parameter is a non-interfering action to be performed on the elements.Create an IntStream and add elements to the streamIntStream intStream = IntStream.of(50, 70, 80, 100, 130, 150, 200);Now, use the forEachOrdered() method to display the stream elements in orderintStream.forEachOrdered(System.out::println);The following is an example to implement IntStream forEachOrdered() method in JavaExampleimport java.util.*; import java.util.stream.IntStream; public class Demo { public static void main(String[] args) { ...

Read More

DoubleStream of() method in Java

Ankith Reddy
Ankith Reddy
Updated on 11-Mar-2026 279 Views

The DoubleStream class in Java the following two forms of the of() methodThe following of() method returns a sequential DoubleStream containing a single element. Here is the syntaxstatic DoubleStream of(double t)Here, parameter t is the single element.The following of() method returns a sequential ordered stream whose elements are the specified valuesstatic DoubleStream of(double… values)Here, the parameter values are the elements of the new stream.To use the DoubleStream class in Java, import the following packageimport java.util.stream.DoubleStream;The following is an example to implement DoubleStream of() method in JavaExampleimport java.util.stream.DoubleStream; public class Demo { public static void main(String[] args) { ...

Read More

The toArray(T[] a) method of CopyOnWriteArrayList in Java

Chandu yadav
Chandu yadav
Updated on 11-Mar-2026 151 Views

The difference between toArray() and toArray(T[] arr) of the CopyOnWriteArrayList class is that both the methods returns an array containing all of the elements in this collection, but the latter has some additional features i.e. the runtime type of the returned array is that of the specified array.The syntax is as followspublic T[] toArray(T[] arr)Here, the parameter arr is the array into which the elements of the list are to be stored.To work with CopyOnWriteArrayList class, you need to import the following packageimport java.util.concurrent.CopyOnWriteArrayList;The following is an example to implement CopyOnWriteArrayList class toArray() method in JavaExampleimport java.util.Arrays; import java.util.concurrent.CopyOnWriteArrayList; ...

Read More
Showing 481–490 of 4,498 articles
« Prev 1 47 48 49 50 51 450 Next »
Advertisements