Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,7 @@ protected static <T> T parse(Class<T> cls, String value)
} else if (cls.isInstance(new Date())) {
Object o = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not part of this change, but this variable is never used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't make unrelated changes in a PR, otherwise the PRs would become unclear easily. I'll see if I can open a new PR cleaning up unused variables.

DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
df.setTimeZone(TimeZone.getTimeZone("UTC"));
return (T) df.parse(value);
} else if (cls.isInstance(Boolean.valueOf(false)))
// else if( cls.isInstance(new Boolean(false)))
Expand Down Expand Up @@ -878,6 +879,7 @@ protected static void validateParamCollection(EventType[] eventTypes,
static String dateTimeToXSDate(Date date) {
String format = "yyyy-MM-dd'Z'";
DateFormat utcFormatter = new SimpleDateFormat(format);
utcFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
return utcFormatter.format(date);
}

Expand All @@ -891,6 +893,7 @@ static String dateTimeToXSDate(Date date) {
protected static String dateTimeToXSDateTime(Date date) {
String format = "yyyy-MM-dd'T'HH:mm:ss'Z'";
DateFormat utcFormatter = new SimpleDateFormat(format);
utcFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
return utcFormatter.format(date);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,21 +499,25 @@ protected Date convertUniversalDateTimeStringToDate(String dateString) {
if (dateString.endsWith("Z")) {
// String in UTC format yyyy-MM-ddTHH:mm:ssZ
utcFormatter = new SimpleDateFormat(utcPattern);
utcFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
try {
dt = utcFormatter.parse(dateString);
} catch (ParseException e) {
utcFormatter = new SimpleDateFormat(pattern);
utcFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
// dateString = dateString.substring(0, 10)+"T12:00:00Z";
try {
dt = utcFormatter.parse(dateString);
} catch (ParseException e1) {
utcFormatter = new SimpleDateFormat(localPattern1);
utcFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));

try {
dt = utcFormatter.parse(dateString);
}catch(ParseException ex){
} catch (ParseException ex){

utcFormatter = new SimpleDateFormat(utcPattern1);
utcFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
}
try{
dt = utcFormatter.parse(dateString);
Expand All @@ -528,6 +532,7 @@ protected Date convertUniversalDateTimeStringToDate(String dateString) {
} else if (dateString.endsWith("z")) {
// String in UTC format yyyy-MM-ddTHH:mm:ssZ
utcFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'z'");
utcFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
try {
dt = utcFormatter.parse(dateString);
} catch (ParseException e) {
Expand All @@ -547,10 +552,12 @@ protected Date convertUniversalDateTimeStringToDate(String dateString) {
dateString = String.format("%sGMT%s", date, zone);
try {
utcFormatter = new SimpleDateFormat(localPattern);
utcFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
dt = utcFormatter.parse(dateString);
} catch (ParseException e) {
try {
utcFormatter = new SimpleDateFormat(pattern);
utcFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
dt = utcFormatter.parse(dateString);
} catch (ParseException ex) {
throw new IllegalArgumentException(ex);
Expand All @@ -559,9 +566,10 @@ protected Date convertUniversalDateTimeStringToDate(String dateString) {
} else {
// Invalid format
utcFormatter = new SimpleDateFormat(localPattern2);
utcFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
try {
dt = utcFormatter.parse(dateString);
} catch (ParseException e) {
} catch (ParseException e) {
e.printStackTrace();
throw new IllegalArgumentException(errMsg);
}
Expand All @@ -580,16 +588,16 @@ protected Date convertUniversalDateTimeStringToDate(String dateString) {
* The string value to parse.
* @return The parsed DateTime value.
*/
protected Date convertStartDateToUnspecifiedDateTime(String value)
protected Date convertStartDateToUnspecifiedDateTime(String value)
throws ParseException {
if (value == null || value.isEmpty()) {
return null;
} else {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'Z'");
if (value == null || value.isEmpty()) {
return null;
} else {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'Z'");
return df.parse(value);
}
}
}
}

/**
* Converts the date time to universal date time string.
*
Expand All @@ -598,10 +606,9 @@ protected Date convertStartDateToUnspecifiedDateTime(String value)
* @return String representation of DateTime in yyyy-MM-ddTHH:mm:ssZ format.
*/
protected String convertDateTimeToUniversalDateTimeString(Date dt) {

DateFormat utcFormatter = null;
String utcPattern = "yyyy-MM-dd'T'HH:mm:ss'Z'";
utcFormatter = new SimpleDateFormat(utcPattern);
DateFormat utcFormatter = new SimpleDateFormat(utcPattern);
utcFormatter.setTimeZone(TimeZone.getTimeZone("UTC"));
return utcFormatter.format(dt);
}

Expand Down