Android - getTimeZone returning date

Asked

Viewed 15 times

0

My command returns in System only the hours, but when it is posted in the database displays the time and date.

I’d like you to return only the hours, which is wrong?

 Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT-3:00"));
    Date currentLocalTime = cal.getTime();
    DateFormat date = new SimpleDateFormat("HH:mm");
    // you can get seconds by adding  "...:ss" to it
    date.setTimeZone(TimeZone.getTimeZone("GMT-3:00"));
  final  String localTime = date.format(currentLocalTime);

            Hours = localTime;


  System.out.println(localTime);

Exit:

I/System.Oct: 09:54

Bank post ..

  postDataParams.put("hora_anun", Hours);
  • You are recording in the bank date and time or time only?

  • In the bank the column was only to save the hours ,as in the system ... But it saves this way "2017-06-30 09:54:00"

  • I’m not seeing the moment you’re saving in the bank. Are you sure you’re saving the correct variable?! There’s no way to reproduce here.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.