EXTRACT DAY FROM THE GIVEN DATE

  The day of the week can be easily extracted from the date given to us. The logic behind this program is to create a calendar object and set the calendar entries as per your requirements. After that we use getWeekdays() method and pass the integer value of days of the week to get the … Continue reading EXTRACT DAY FROM THE GIVEN DATE

Difference Between Two String

The following JAVA PROGRAM calculates the difference between two strings provided the initial contents in both the strings remain the same.   The logic behind this program is to consider the lengths of the two strings. If the first string is having larger length, then it is divided to get the difference and same goes … Continue reading Difference Between Two String

CALCULATE DIFFERENCE BETWEEN TWO DATES

CALCULATE DIFFERENCE BETWEEN TWO DATES This program calculates the difference between two dates. This difference which is basically in milliseconds is then converted into the number of days, hours, minutes and seconds. package samples; import java.text.SimpleDateFormat; import java.util.Date; public class DifferenceBetweenTwoDates{ public static void main(String[] args) { String dateStart = "01/14/2012 09:29:58"; String dateStop = … Continue reading CALCULATE DIFFERENCE BETWEEN TWO DATES