I want to convert the incoming date from MM-dd-yyyy which is the format on the front end, and convert it to the format yyyy-MM-dd. This is useful since the backend query requires the format to be yyyy-MM-dd. I am having trouble with the syntax. I know when I do Date = new Date(), that only initializes for today's date but I want the paramater to be the incoming date that the user selects, which can be whatever it wants to be. I have two date formats set up:
public final static String getConvertedDate()
{
DateFormat userFormat = new SimpleDateFormat(MM-dd-yyyy);
DateFormat neededFormat = new SimpleDateFormat(yyyy-MM-dd);
//now I want to set it up to where I have a date the user selects
Date date = new Date() //I feel like I should input a parameter for any given date in Date() but am //unsure
//return statement returning the neededFormat
}
I may or may not be setting it up properly and am unsure if I need to set up two DateFormats like that. Any help would be much appreciated. Thanks!