I am concatenating two edittext boxes. One has date and the other has time. I then change them into a time and store them into the db. I ran the debugger and the date object seems to be correct until I convert it into an int, then it is not converting correctly. Here is my code
Time userTime;
userTime= new Time(date.getText().toString().concat(time.getText().toString()));
int enteredTime = (int) ((userTime).toMillis(true) / 1000);
UpDate: For some reason all the info is going under the timezone for userTime?? Any have any ideas why
int enteredTime = (int) ((userTime).toMillis(true) / 1000);
It is always better to store time in long than int. I guess it could be the reason why you are seeing wrong time.
Try something like this below:
long enteredTime = (long) ((userTime).toMillis(true) / 1000);
Where are you using the converted time? Most java code likes milliseconds rather than seconds, so try omitting the division by 1000. Be sure you use a long
rather than an int
in this case.