Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void calcular(View view) {
- if(d.getId()>0){
- SimpleDateFormat formato = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
- Date inicio = new Date();
- try{
- inicio = formato.parse(d.getEntrada());
- }catch(Exception ex){
- ex.printStackTrace();
- }
- Date fin = new Date();
- try{
- fin = formato.parse(d.getSalida());
- }catch(Exception ex){
- ex.printStackTrace();
- fin = new Date();
- d.setSalida(formato.format(fin));
- }
- long diff = fin.getTime() - inicio.getTime();
- int tiempo = (int) (diff/1000/60);
- int horas = 0;
- try{
- horas = Integer.parseInt(montoPorHora.getText().toString().trim());
- }catch(NumberFormatException ex){
- ex.printStackTrace();
- }
- //int tiempo = (int)(TimeUnit.HOURS.convert(diff, TimeUnit.MILLISECONDS));
- int total = tiempo * horas;
- d.setTotal(total);
- //Toast.makeText(view.getContext(), "Total: $"+total, Toast.LENGTH_SHORT).show();
- labelTotal.setText("Total para id "+d.getId()+" $"+d.getTotal());
- }else{
- Toast.makeText(this, "LUL", Toast.LENGTH_SHORT).show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement