Nancy Den has Published 330 Articles

LocalTime getSecond() method in Java

Nancy Den

Nancy Den

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

95 Views

The second of minute for a particular LocalTime can be obtained using the getSecond() method in the LocalTime class in Java. This method requires no parameters and it returns the second of the minute in the range of 0 to 59.A program that demonstrates this is given as followsExample Live Demoimport ... Read More

C++ Program to Check Whether a Directed Graph Contains a Eulerian Cycle

Nancy Den

Nancy Den

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

461 Views

The Euler cycle/circuit is a path; by which we can visit every edge exactly once. We can use the same vertices for multiple times. The Euler Circuit is a special type of Euler path. When the starting vertex of the Euler path is also connected with the ending vertex of ... Read More

LocalTime hashCode() method in Java

Nancy Den

Nancy Den

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

91 Views

The hash code value of the LocalTime can be obtained using the hashCode() method in the LocalTime class in Java. This method requires no parameters and it returns the hash code value of the LocalTime.A program that demonstrates this is given as followsExample Live Demoimport java.time.*; public class Demo { public ... Read More

C++ Program to Implement the linear congruential generator for Pseudo Random Number Generation

Nancy Den

Nancy Den

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

888 Views

The linear congruential generator is a very simple example of a random number generator. It is one of the oldest and best-known pseudorandom number generator algorithms. The function which is used in this method −Xn+1=(aXn + C) mod mwhere X is the sequence of pseudorandom values, andm,0

LocalTime ofSecondOfDay() method in Java

Nancy Den

Nancy Den

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

72 Views

A LocalTime object can be obtained using the seconds of the day with the ofSecondOfDay() method in the LocalTime class in Java. This method requires a single parameter i.e. the seconds of the day and it returns the LocalTime object for the seconds of the day.A program that demonstrates this ... Read More

LocalTime equals() method in Java

Nancy Den

Nancy Den

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

306 Views

The equality of two LocalTime objects can be determined using the equals() method in the LocalTime class in Java. This method requires a single parameter i.e. the LocalTime object to be compared. Also it returns true if both the LocalTime objects are equal and false otherwise.A program that demonstrates this ... Read More

C++ Program to Generate Random Numbers Using Middle Square Method

Nancy Den

Nancy Den

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

908 Views

The middle-square method is one of the simplest method of generating random numbers. this method will either begin repeatedly generating the same number or cycle to a previous number in the sequence and loop indefinitely. For a generator of ndigit random numbers, the period can be no longer than n. ... Read More

Iterate through KeyValue Tuple in Java

Nancy Den

Nancy Den

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

334 Views

To iterate through the KeyValue tuple in Java, use the Iterable and loop it through using the for loop. Let us first see what we need to work with JavaTuples. To work with KeyValue class in JavaTuples, you need to import the following package:import org.javatuples.KeyValue;Note: Download JavaTuples Jar library to ... Read More

Java Program to add Period to LocalDate

Nancy Den

Nancy Den

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

383 Views

Let us first set a Period with month and days:Period p = Period.ofMonths(5).plusDays(15);Now set the LocalDate:LocalDate date = LocalDate.of(2019, 4, 10);Add period to LocalDate:LocalDate res = date.plus(p);Exampleimport java.time.LocalDate; import java.time.Period; public class Demo {    public static void main(String[] args) {       Period p = Period.ofMonths(5).plusDays(15);     ... Read More

How to get days, months and years between two Java LocalDate?

Nancy Den

Nancy Den

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

846 Views

Set the two Java dates:LocalDate date1 = LocalDate.of(2019, 3, 25); LocalDate date2 = LocalDate.of(2019, 4, 29);Now, get the difference between two dates with Period class between() method:Period p = Period.between(date1, date2);Now, get the years, month and days:p.getYears() p.getMonths() p.getDays()Exampleimport java.time.LocalDate; import java.time.Period; public class Demo {    public static void ... Read More

Advertisements