Question Index

Write a program to create the advanced time String for the distance between two dates. In the string Y represents Years, L represents Leap Year, M for Months, W for Weeks, S represents Sunday or Saturday, M represents Monday, T represents Tuesday or Thursday, W represents Wednesday, F represents Friday.
Note : If the start date is greater than end date return -1. If both dates are same, then return empty string.

Input (String, String) Output (String)
01-Jan-2000, 09-Dec-2003 LYYMMMMMMMMMMMWT
28-Jan-2000, 01-Mar-2000 MTW
15-Aug-2001, 15-July-2002 MMMMMMMMMMM
05-Sept-2009, 08-Oct-2008 -1
28-Jan-1995, 14-Oct-1997 YLMMMMMMMMWWMT

class CreateAdvancedTimeString

{    public static void main(String s[])
        String startDate = "12-Feb-1998", endDate = "01-Mar-2000";
        String timeString = createAdvancedTimeString(startDate, endDate);
        System.out.println("The Time String is " + timeString);


public static String createAdvancedTimeString(String first, String last) {
//Write code here to get the time string in the required format



Topic: Locale Class In Java

Read this topic
Take test on this topic

Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App