After a lot of searching. I found this method. Bit annoying but it works
java.sql.Timestamp tsStart = java.sql.Timestamp.valueOf(year+ "-" + month + "-" + day + " " + hour + ":"+ minute + ":00"); java.sql.Timestamp tsStart = java.sql.Timestamp.valueOf(year+ "-" + month + "-" + day + " " + hour2+ ":"+ minute2+ ":00"); long startTime = tsStart.getTime(); long endTime = tsEnd.getTime();
I was just hoping I could use the Calendar method to set the date and time, although guessing really doesn't matter. Also customize people using this method, make sure your month to month fields, etc. Conform to timestamp format. In my application, when I clicked on the agenda, a date and time string would be required for that date, and then I split it like this:
String array[] = tvSessionTime.getText().toString().split(" "); String array2[] = array[0].split(":"); int iHour = Integer.parseInt(array2[0]) int sMinute = Integer.parseInt(array2[0]) String array3[] = tvSessionDate.getText().toString().split(" ");
And if you had time, like 07.05, and you sorted out the hour, the hour will return as 7, and the minute will return as 5. And the format will be yyyy-hh-mm. So this led to an error, as it did not match the date format. Just a head!
Adamm source share