title: Getting the same hours:minutes in Android
body: <p>Every time I try to get the current time (I have a button for that, lets call it "botonGuardarEstado") I get the same hours and minutes. What I have noted is that the time I got is the time when I opened the app. What I mean is, if I opened the app at 7:10 a.m. and press the button at 7:12 a.m., I get 7:10 a.m. Here is my code:</p>
  
  <pre><code>DateFormat formatoFecha = new SimpleDateFormat("HH:mm dd/MM/yyyy");
  String fecha = formatoFecha.format(Calendar.getInstance().getTime());
  </code></pre>
  
  <p>I am not getting weird values like different years or anything like that, and the format works well, the problem is that i get the same hours:minutes everytime i push the button. I alredy tried different ways of getting the date and time, things like Date(), or even getting only the hours and minutes using something like this</p>
  
  <pre><code>Calendar cal = Calendar.getInstance();
  int mins = cal.get(Calendar.MINUTE);
  </code></pre>
  
  <p>but still got the same values.</p>
  
  <p>I have the following class</p>
  
  <pre><code>private class InfoArchivo {
      String temperatura, humedad, gas, humo, iluminacion, riego, ventilacion, fecha;
  
      public InfoArchivo(String temperatura, String humedad, String gas, String humo, String iluminacion, String riego, String ventilacion, String fecha){
          this.temperatura = temperatura;
          this.humedad = humedad;
          this.gas = gas;
          this.humo = humo;
          this.iluminacion = iluminacion;
          this.riego = riego;
          this.fecha = fecha;
  
          if(!ventilacion.equals("0"))
              this.ventilacion = "1";
          else
              this.ventilacion = "0";
      }
  </code></pre>
  
  <p>I have an array of instances of that class. What i am trying to do is write a csv file using the array. Every other data (temperatura, humedad, etc) is correct. The only thing causing trouble is the date (fecha). The creation of the csv file is done until i press another button. When i press the botonGuardarEstado button i get the date, make an instance of the class InfoArchivo and add it to the array</p>
  
  <p>EDIT: Also tried with this but still have the same issue:</p>
  
  <pre><code>Instant instant = Instant.now();
          ZoneId zoneId = ZoneId.of("America/Guatemala");
          ZonedDateTime zdt = ZonedDateTime.ofInstant(instant, zoneId);
          DateTimeFormatter formato = DateTimeFormatter.ofPattern("HH:mm dd/MM/yyyy");
          String fecha = zdt.format(formato);
  </code></pre>