Additional Java SE Packages

LocalDateTime

java.time.LocalDateTime represents a date and time without a time zone. It is a combination of LocalDate and LocalTime. Commonly Used Methods Simple Program Problem Statement LotusJavaPrince and Mahesh are building a meeting reminder system for employees. Each reminder must be scheduled precisely with date and time. The system should: Take input for meeting date and …

LocalDateTime Read More »

LocalTime class

The java.time.LocalTime class represents a time without a date and without time zone information, using hour, minute, second, and nanosecond. Commonly Used Methods Simple Program Problem Statement LotusJavaPrince and LotusPythonPrince are creating a conference room scheduler for the TechMind Event Center. Each room has defined opening and closing times. They need to: Accept user input …

LocalTime class Read More »

LocalDate

The java.time.LocalDate class represents a date without time (year, month, day) in the ISO-8601 calendar system. It does not include time or timezone information. Commonly Used Methods Simple Program Problem Statement Paani and Mahesh are building a customer onboarding system for LoanTrust Bank. The system needs to: Capture the customer’s date of birth. Calculate the …

LocalDate Read More »

Peroid class

The java.time.Period class represents a date-based amount of time in terms of years, months, and days. It is used to model calendar-based differences, like “2 years and 3 months” or “10 days”. Commonly Used Methods Simple Program Problem Statement LotusJavaPrince and Mahesh are building a loan management system for Sunrise Microfinance. The requirement is: When …

Peroid class Read More »

Duration class

The java.time.Duration class models a time-based amount of time measured in seconds and nanoseconds. It is ideal for measuring time between two Instant values or defining fixed time periods (e.g., wait 5 seconds, time out after 2 minutes). Commonly Used Methods  Simple Program Problem Statement LotusJavaPrince and LotusPythonPrince are working on a performance monitoring system …

Duration class Read More »

Instant class

The java.time.Instant class represents a specific moment on the time-line in UTC (Coordinated Universal Time). It is a machine-readable timestamp and is commonly used for recording timestamps in logs, measuring time intervals, or working with system clocks. It is immutable and thread-safe. The epoch reference point is 1970-01-01T00:00:00Z (UTC). Commonly Used Methods of Instant Simple …

Instant class Read More »

ArithmeticException for BigDecimal

The BigDecimal class is designed for high-precision arithmetic, especially when dealing with monetary or scientific calculations. However, despite its flexibility, ArithmeticException can still occur — most notably when the result of an operation cannot be represented exactly under the conditions provided (e.g., during division without a specified rounding mode). Why Does ArithmeticException Occur with BigDecimal? …

ArithmeticException for BigDecimal Read More »

ArithmeticException for BigInteger

The BigInteger class represents arbitrary-precision integers and does not support fractional or decimal values. Therefore, RoundingMode.HALF_UP and other rounding modes are not applicable to BigInteger operations directly. However, you may still encounter an ArithmeticException in certain cases when converting or dividing with expectations of exact results, especially when the operation would require rounding, something BigInteger …

ArithmeticException for BigInteger Read More »

Scroll to Top