Here's the scenario. User enters 3 types of inputs:
1/1/2013 12:00:00 AM_5/31/2013 12:00:00 AM
1/1/2013 12:00:00 AM_
_5/31/2013 12:00:00 AM
The input is for date range query.
1st input: Split by the _ delimiter: Broken into Start date and end date.
2nd input: Split by the _ delimiter: Input is only the start date.
3rd input: Split by the _ delimiter: Input is only the end date.
Input is retrieved by generic return type
String dbFormat = AppConstant.DB_DATE_FORMAT;
String format = AppConstant.DATE_FORMAT;
SimpleDateFormat df = new SimpleDateFormat(format);
df.setTimeZone(TimeZone.getTimeZone("UTC"));
String dates[] = searchValue.split("_", -1);
String start = "".equals(dates[0]) ? df.format(new Date(0L)) : dates[0];
String end = "".equals(dates[1]) ? df.format(new Date()) : dates[1];
filters.add(String.format("%s between to_date('%s', '%s') and to_date('%s', '%s')", columnKey, start, dbFormat, end, dbFormat));
The part that I need help on is,the date for the variable start and end should be in UTC format.As you guys can see, I've managed to convert new Date(0L) and new Date() to UTC format.
But I cant seem to format dates[0] and dates[1] to UTC.
Any ideas how to convert dates[0] and dates[1] into UTC time format? Can it be done in the same line.
I tried df.format(dates[0]) but its not working.
I'm sorry if I may sound like a nood, but I'm new to java and I'm learning each day.
Thanks alot in advance.