Example #1
0
  @SuppressWarnings("deprecation")
  @Override
  public void onReceive(Context context, Intent intent) {
    Toast.makeText(context, "Alarm received!", Toast.LENGTH_LONG).show();

    int endDay = intent.getIntExtra("endDay", -1);
    int endMonth = intent.getIntExtra("endMonth", -1);
    int endYear = intent.getIntExtra("endYear", -1);
    int interval = intent.getIntExtra("interval", -1);
    int id = intent.getIntExtra("id", -1);
    Bundle arguments = intent.getExtras().getBundle("arguments");

    Date date = new Date();
    date = new Date(date.getTime() + interval * 3600 * 1000);
    Log.d("Debug", date.getYear() + " an");
    if (date.getYear() + 1900 > endYear) {
      cancelIntent(context, id, intent);
    } else if (date.getYear() + 1900 == endYear) {
      if (date.getMonth() > endMonth) {
        cancelIntent(context, id, intent);
      } else if (date.getMonth() == endMonth) {
        if (date.getDate() >= endDay) {
          cancelIntent(context, id, intent);
        }
      }
    }
    intent = new Intent(context, MedDetailActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra("fromAlarm", true);
    intent.putExtra("arguments", arguments);
    context.startActivity(intent);
  }
Example #2
0
  @SuppressWarnings("deprecation")
  private static boolean shallSendToday(Date sendDate, Schedule schedule) {

    int diffUnit;
    if (Schedule.CALC_UNIT_DAY == schedule.calUnit) {
      Calendar calToday = Calendar.getInstance(TimeZone.getTimeZone("GMT 0:00"));
      Calendar calSendDate = Calendar.getInstance(TimeZone.getTimeZone("GMT 0:00"));
      calSendDate.set(sendDate.getYear() + 1900, sendDate.getMonth(), sendDate.getDate());
      long daysToday = calToday.getTimeInMillis() / MILISECONDS_ONE_DAY;
      long daysSendDate = calSendDate.getTimeInMillis() / MILISECONDS_ONE_DAY;
      diffUnit = (int) (daysToday - daysSendDate);
    } else {
      Date today = new Date();
      if (today.getDate() != sendDate.getDate()) {
        return false;
      }
      int amoutSendDate = sendDate.getYear() * 12 + sendDate.getMonth();
      int amoutToday = today.getYear() * 12 + today.getMonth();
      diffUnit = amoutSendDate - amoutToday;
    }
    schedule.realAmount = diffUnit / schedule.calAmout * schedule.amount;
    schedule.realAmount = schedule.realAmount > 0 ? schedule.realAmount : -schedule.realAmount;
    boolean onSchedule = diffUnit % schedule.calAmout == 0;
    return onSchedule;
  }
Example #3
0
 /**
  * 获取更新的时间
  *
  * @param date
  * @return
  */
 public static String getCreateString_PG(Date date) {
   Calendar calendar = Calendar.getInstance();
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
   if (calendar.get(Calendar.YEAR) - (date.getYear() + 1900) > 0) {
     return sdf.format(date);
   } else if (calendar.get(Calendar.MONTH) - date.getMonth() > 0
       && calendar.get(Calendar.MONTH) - date.getMonth() < 12) {
     int i = calendar.get(Calendar.MONTH) - date.getDate();
     return i + "个月前";
   } else if ((calendar.get(Calendar.DAY_OF_MONTH) - date.getDate() > 0)
       && (calendar.get(Calendar.DAY_OF_MONTH) - date.getDate() < 30)) {
     int i = calendar.get(Calendar.DAY_OF_MONTH) - date.getDate();
     return i + "天前";
   } else if (calendar.get(Calendar.HOUR_OF_DAY) - date.getHours() > 0) {
     int i = calendar.get(Calendar.HOUR_OF_DAY) - date.getHours();
     return i + "小时前";
   } else if (calendar.get(Calendar.MINUTE) - date.getMinutes() > 0) {
     int i = calendar.get(Calendar.MINUTE) - date.getMinutes();
     return i + "分钟前";
   } else if (calendar.get(Calendar.SECOND) - date.getSeconds() > 0) {
     int i = calendar.get(Calendar.SECOND) - date.getSeconds();
     return i + "秒前";
   } else if (calendar.get(Calendar.SECOND) - date.getSeconds() == 0) {
     return "刚刚";
   } else {
     return sdf.format(date);
   }
 }
Example #4
0
 public PanelAgendarViaje() {
   initComponents();
   this.sistema = SistemaImp.getInstance();
   if (this.sistema.esModoDesarrollador()) {
     this.txtNombre.requestFocusInWindow();
     if (sistema.getListaDestinos().isEmpty()) {
       sistema.agregarDestino(new Ciudad("Miami"));
     }
     this.txtNombre.setText("Vacaciones");
     this.txtDescripcion.setText("Nos vamos de vacaciones con la familia.");
   } else {
     this.txtNombre.requestFocusInWindow();
   }
   Iterator<Ciudad> listadoDestino = sistema.listadoDestino();
   while (listadoDestino.hasNext()) {
     Ciudad ciudad = listadoDestino.next();
     comboDestino.addItem(ciudad);
   }
   etqError2.setText("");
   Date fecha = new Date();
   Date maniana = new Date(fecha.getYear(), fecha.getMonth(), fecha.getDate() + 1);
   JDateInicio.setDate(maniana);
   Date pasadoManiana = new Date(fecha.getYear(), fecha.getMonth(), fecha.getDate() + 2);
   JDateFin.setDate(pasadoManiana);
 }
Example #5
0
  public boolean isEaster() {
    int year = new Date().getYear() + 1900;
    int a = year % 19;
    int b = year / 100;
    int c = year % 100;
    int d = b / 4;
    int e = b % 4;
    int f = (b + 8) / 25;
    int g = (b - f + 1) / 3;
    int h = (19 * a + b - d - g + 15) % 30;
    int i = c / 4;
    int k = c % 4;
    int l = (32 + 2 * e + 2 * i - h - k) % 7;
    int m = (a + 11 * h + 22 * l) / 451;
    int easterMonth = (h + l - 7 * m + 114) / 31;
    int easterDay = (h + l - 7 * m + 114) % 31 + 1;
    //        System.out.println("easter this year was: " + easterDay + "/" + easterMonth + " " +
    // year);

    Date now = new Date();
    Date easter = new Date();
    easter.setMonth(easterMonth);
    easter.setDate(easterDay);

    // todo make this last more than 1 day :)
    return (now.getMonth() + 1) == easter.getMonth() && now.getDate() == easter.getDate();
  }
Example #6
0
  /**
   * * 返回多少天后的具体日期
   *
   * @param year
   * @param mouth
   * @param date
   * @return
   */
  public static String getForMyBrithdayToDate(long day) {

    Calendar calendar = Calendar.getInstance(Locale.US);
    calendar.setTime(new Date());

    long now = calendar.getTimeInMillis();

    long nextBirthMillionSeconds = day * 24 * 60 * 60 * 1000;
    long kk = now + nextBirthMillionSeconds;
    Date date2 = new Date();
    date2.setTime(kk);
    Calendar ca = Calendar.getInstance();
    ca.set(Calendar.YEAR, date2.getYear() + 1900);
    ca.set(Calendar.MONTH, date2.getMonth() + 1 - 1); // 也可以填数字,0-11,一月为0
    ca.set(Calendar.DAY_OF_MONTH, date2.getDay() + 1);
    lunner kkq = new lunner(ca);
    String str =
        (date2.getYear() + 1900)
            + "年"
            + (date2.getMonth() + 1)
            + "月"
            + (date2.getDay() + 1)
            + "日("
            + kkq.toString()
            + ")";
    return str;
  }
Example #7
0
  @SuppressWarnings("deprecation")
  private String getDisplayTime(String datetime) {

    try {
      SimpleDateFormat sourceFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      sourceFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
      Date parsed = sourceFormat.parse(datetime); // => Date is in UTC now

      TimeZone tz = TimeZone.getDefault();
      SimpleDateFormat destFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      destFormat.setTimeZone(tz);

      String result = destFormat.format(parsed);

      Date dt = sdf.parse(result);
      if (now.getYear() == dt.getYear()
          && now.getMonth() == dt.getMonth()
          && now.getDate() == dt.getDate()) {
        return tformat.format(dt);
      }
      return dformat.format(dt);
    } catch (Exception e) {
    }
    return "";
  }
 public void adjustDate(Date d) {
   if (DateIntervalType.MILLENIUM.equals(type)) {
     d.setYear(d.getYear() + (int) quantity * 1000);
   }
   if (DateIntervalType.CENTURY.equals(type)) {
     d.setYear(d.getYear() + (int) quantity * 100);
   }
   if (DateIntervalType.DECADE.equals(type)) {
     d.setYear(d.getYear() + (int) quantity * 10);
   }
   if (DateIntervalType.YEAR.equals(type)) {
     d.setYear(d.getYear() + (int) quantity);
   }
   if (DateIntervalType.QUARTER.equals(type)) {
     d.setMonth(d.getMonth() + (int) quantity * 3);
   }
   if (DateIntervalType.MONTH.equals(type)) {
     d.setMonth(d.getMonth() + (int) quantity);
   }
   if (DateIntervalType.WEEK.equals(type)) {
     d.setDate(d.getDate() + (int) quantity * 7);
   }
   if (DateIntervalType.DAY.equals(type)) {
     d.setDate(d.getDate() + (int) quantity);
   }
   if (DateIntervalType.HOUR.equals(type)) {
     d.setHours(d.getHours() + (int) quantity);
   }
   if (DateIntervalType.MINUTE.equals(type)) {
     d.setMinutes(d.getMinutes() + (int) quantity);
   }
   if (DateIntervalType.SECOND.equals(type)) {
     d.setSeconds(d.getSeconds() + (int) quantity);
   }
 }
Example #9
0
 public static String getEarlyTime(long time, boolean showWeek) {
   String strTime;
   long dif = System.currentTimeMillis() - time;
   if (dif < 1000 * 60) {
     strTime = "刚刚";
   } else if (dif < 1000 * 60 * 60) {
     strTime = dif / 1000 / 60 + "分钟前";
   } else {
     Date dt = new Date(time);
     Date curDate = new Date();
     String timePattern = showWeek ? " E HH:mm" : " HH:mm";
     if (dt.getYear() == curDate.getYear()) {
       if (dt.getMonth() == curDate.getMonth() && dt.getDate() == curDate.getDate()) {
         SimpleDateFormat sdf = new SimpleDateFormat("今天" + timePattern);
         strTime = sdf.format(dt);
       } else if (dt.getMonth() == curDate.getMonth() && dt.getDate() == curDate.getDate() - 1) {
         SimpleDateFormat sdf = new SimpleDateFormat("昨天" + timePattern);
         strTime = sdf.format(dt);
       } else {
         SimpleDateFormat sdf = new SimpleDateFormat("MM月dd日" + timePattern);
         strTime = sdf.format(dt);
       }
     } else {
       SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日" + timePattern);
       strTime = sdf.format(dt);
     }
   }
   return strTime;
 }
  /**
   * This method figures out the months between the current date and the date given.
   *
   * @param d The given date.
   * @return Months between the two dates.
   */
  public int getMonthsOld(Date d) {
    Date actual = new Date();

    int actual_months = (actual.getMonth() + 1) + (actual.getYear() * 12);
    int d_months = (d.getMonth() + 1) + (d.getYear() * 12);

    return actual_months - d_months;
  }
Example #11
0
 @SuppressWarnings("deprecation")
 public Date merge(Date date1, Date date2) {
   int preciseLevel1 =
       date1 == null ? 0 : date1.getDate() != 1 ? 3 : date1.getMonth() != 0 ? 2 : 1;
   int preciseLevel2 =
       date2 == null ? 0 : date2.getDate() != 1 ? 3 : date2.getMonth() != 0 ? 2 : 1;
   return preciseLevel1 >= preciseLevel2 ? date1 : date2;
 }
Example #12
0
  // returns true if the 2 days are the same
  protected boolean isDayEqualToExistingEventDay(Date existing, Date incoming) {

    Date existingDay = new Date(existing.getYear(), existing.getMonth(), existing.getDate());
    Date incomingDay = new Date(incoming.getYear(), incoming.getMonth(), incoming.getDate());

    if (existingDay.compareTo(incomingDay) == 0) return true;
    else return false;
  }
Example #13
0
 @SuppressWarnings("deprecation")
 public static boolean isDayChanged(long lastScan) {
   Date last = new Date(lastScan);
   Date now = new Date();
   long lastlong = Date.UTC(last.getYear(), last.getMonth(), last.getDay(), 0, 0, 0);
   long nowlong = Date.UTC(now.getYear(), now.getMonth(), now.getDay(), 0, 0, 0);
   return lastlong != nowlong;
 }
Example #14
0
 @Transient
 public float getPreu(Date di, Date df) {
   float r = getSuplement();
   int dies =
       (df.getYear() - di.getYear()) * 365
           + (df.getMonth() - di.getMonth()) * 30
           + (df.getDate() - di.getDate());
   return (preu + r) * dies;
 }
  /**
   * Compare month year.
   *
   * @param userBirthDate the user birth date
   * @param dbPatientBirthDate the db patient birth date
   * @return true, if successful
   */
  private boolean compareMonthYear(Date userBirthDate, Date dbPatientBirthDate) {
    boolean flag = false;
    if (userBirthDate.getMonth() == dbPatientBirthDate.getMonth()
        && userBirthDate.getYear() == dbPatientBirthDate.getYear()) {

      flag = true;
    }
    return flag;
  }
Example #16
0
 /**
  * Returns true if the specified date is within today. Returns false otherwise.
  *
  * @param date
  * @return
  */
 public static boolean isDateToday(Date date) {
   // TODO But Calendar is so slowwwwwww....
   Date today = new Date();
   if (date.getYear() == today.getYear()
       && date.getMonth() == today.getMonth()
       && date.getDate() == today.getDate()) {
     return true;
   }
   return false;
 }
Example #17
0
 private void limpiarCampos() {
   txtNombre.setText("");
   txtDescripcion.setText("");
   comboDestino.setSelectedIndex(0);
   Date fecha = new Date();
   Date maniana = new Date(fecha.getYear(), fecha.getMonth(), fecha.getDate() + 1);
   JDateInicio.setDate(maniana);
   Date pasadoManiana = new Date(fecha.getYear(), fecha.getMonth(), fecha.getDate() + 2);
   JDateFin.setDate(pasadoManiana);
 }
Example #18
0
    public boolean isLastInSection(int position) {
      if (position == getCount() - 1) return true;

      Date date1 = new Date(getItem(position).getTimestamp() * 1000);
      Date date2 = new Date(getItem(position + 1).getTimestamp() * 1000);

      return ((date1.getYear() != date2.getYear())
          || (date1.getMonth() != date2.getMonth())
          || (date1.getDay() != date2.getDay()));
    }
Example #19
0
    private boolean isFirstInSection(int position) {
      if (position == 0) return true;

      Date date1 = new Date(getItem(position).getTimestamp() * 1000);
      Date date2 = new Date(getItem(position - 1).getTimestamp() * 1000);

      return ((date1.getYear() != date2.getYear())
          || (date1.getMonth() != date2.getMonth())
          || (date1.getDay() != date2.getDay()));
    }
Example #20
0
 @Test
 public void testSaveDate() {
   Date d = new Date();
   java.util.Date dt = new java.util.Date();
   dao.save(d);
   System.out.println(dt.getDay() + "-" + dt.getMonth() + "-" + dt.getYear());
   assertEquals(new Integer(1), d.getId());
   assertEquals(dt.getDay(), d.getDay());
   assertEquals(dt.getMonth(), d.getMonth());
   assertEquals(dt.getYear(), d.getYear());
 }
Example #21
0
  private boolean isUpdatedToday() {
    if (isEmptyOnStart) return false;

    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
    Date lastUpdateDate = new Date(settings.getLong(LAST_UPDATE_DATE, 0));
    Date today = new Date();

    return today.getYear() == lastUpdateDate.getYear()
        && today.getMonth() == lastUpdateDate.getMonth()
        && today.getDate() == lastUpdateDate.getDate();
  }
  /**
   * Compare date month year.
   *
   * @param userBirthDate the user birth date
   * @param dbPatientBirthDate the db patient birth date
   * @return true, if successful
   */
  private boolean compareDateMonthYear(Date userBirthDate, Date dbPatientBirthDate) {
    boolean flag = false;
    if ((userBirthDate.getDate() == dbPatientBirthDate.getDate()
            && userBirthDate.getMonth() == dbPatientBirthDate.getMonth())
        && (userBirthDate.getYear() >= (Math.abs(dbPatientBirthDate.getYear() - 2))
            && userBirthDate.getYear() <= (Math.abs(dbPatientBirthDate.getYear() + 2)))) {
      flag = true;
    }

    return flag;
  }
  public List<Playorder> findPlayorders(Date month, int subject) throws Exception {
    Calendar calendar = new GregorianCalendar();
    calendar.setTime(month);

    Date startDate = new Date(month.getYear(), month.getMonth(), 1);
    Date endDate =
        new Date(
            month.getYear(), month.getMonth(), calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
    List<Playorder> orders =
        playorderDAO.findMonthPlayOrder(startDate, endDate, subject, -1, -1, true);
    return orders;
  }
  @SuppressWarnings("deprecation")
  public static void LogConsole(String type, String info) {
    // Player may be null
    // determine if the log is enabled...
    if (LogIsEnabled) {

      /*
       * File BDir = new File(LogLocation); BDir.mkdir(); File TDir = new
       * File(TLogLocation+type); TDir.mkdir();
       */

      Date date = new Date();

      String LogNameFormatter = LogNameFormat;
      LogNameFormatter = LogNameFormatter.replace("{MONTH}", (date.getMonth() + 1) + "");
      LogNameFormatter = LogNameFormatter.replace("{YEAR}", (date.getYear() + 1900) + "");
      LogNameFormatter = LogNameFormatter.replace("{DAY}", date.getDate() + "");
      LogNameFormatter = LogNameFormatter.replace("{HOUR}", date.getHours() + "");
      LogNameFormatter = LogNameFormatter.replace("{DTYPE}", type);

      // File Log = new
      // File(TLogLocation+esplitter+type+"/"+LogNameFormatter);

      String LogStringFormatter = LogStringFormat;
      LogStringFormatter = LogStringFormatter.replace("{MONTH}", (date.getMonth() + 1) + "");
      LogStringFormatter = LogStringFormatter.replace("{YEAR}", (date.getYear() + 1900) + "");
      LogStringFormatter = LogStringFormatter.replace("{DAY}", date.getDate() + "");
      LogStringFormatter = LogStringFormatter.replace("{HOUR}", date.getHours() + "");
      LogStringFormatter = LogStringFormatter.replace("{MINUTE}", date.getMinutes() + "");
      LogStringFormatter = LogStringFormatter.replace("{SECOND}", date.getSeconds() + "");
      LogStringFormatter = LogStringFormatter.replace("{INFO}", info);

      // tekkitrestrict.log.info(LogStringFormatter);
      final String ttype = type;
      final String formattedName = LogNameFormatter;
      final String formatted = LogStringFormatter;
      final String TLogLocation = "log/";
      tekkitrestrict.basfo.execute(
          new Runnable() {

            @Override
            public void run() {
              LogQueue1.add(
                  new String[] {
                    ttype,
                    TLogLocation + ttype,
                    TLogLocation + ttype + "/" + formattedName,
                    formatted + "\n"
                  });
            }
          });
    }
  }
 private static DateValue setUpStartDateAsDV(Task task, Date startDate) {
   if (task.hasDueTime())
     return new DateTimeValueImpl(
         startDate.getYear() + 1900,
         startDate.getMonth() + 1,
         startDate.getDate(),
         startDate.getHours(),
         startDate.getMinutes(),
         startDate.getSeconds());
   else
     return new DateValueImpl(
         startDate.getYear() + 1900, startDate.getMonth() + 1, startDate.getDate());
 }
  @SuppressWarnings("deprecation")
  public static void Log(String type, String info) {
    // Player may be null

    // determine if the log is enabled...
    if (LogIsEnabled) {
      String TLogLocation = "plugins/tekkitrestrict/" + LogLocation;
      // File BDir = new File(LogLocation);
      // BDir.mkdir();
      // tekkitrestrict.log.info("tt - "+type);
      // ******************if(type.equals("debug")) tekkitrestrict.log.info("log: "+info);
      if (isLoggable(type)) {
        // tekkitrestrict.log.info("tt - "+type);
        String esplitter = !TLogLocation.endsWith("/") ? "/" : "";
        // File TDir = new File(TLogLocation+esplitter+type);
        // TDir.mkdir();

        Date date = new Date();

        String LogNameFormatter = LogNameFormat;
        LogNameFormatter = LogNameFormatter.replace("{MONTH}", (date.getMonth() + 1) + "");
        LogNameFormatter = LogNameFormatter.replace("{YEAR}", (date.getYear() + 1900) + "");
        LogNameFormatter = LogNameFormatter.replace("{DAY}", date.getDate() + "");
        LogNameFormatter = LogNameFormatter.replace("{HOUR}", date.getHours() + "");
        LogNameFormatter = LogNameFormatter.replace("{DTYPE}", type);

        // File Log = new
        // File(TLogLocation+esplitter+type+"/"+LogNameFormatter);

        String LogStringFormatter = LogStringFormat;
        LogStringFormatter = LogStringFormatter.replace("{MONTH}", (date.getMonth() + 1) + "");
        LogStringFormatter = LogStringFormatter.replace("{YEAR}", (date.getYear() + 1900) + "");
        LogStringFormatter = LogStringFormatter.replace("{DAY}", date.getDate() + "");
        LogStringFormatter = LogStringFormatter.replace("{HOUR}", date.getHours() + "");
        LogStringFormatter = LogStringFormatter.replace("{MINUTE}", date.getMinutes() + "");
        LogStringFormatter = LogStringFormatter.replace("{SECOND}", date.getSeconds() + "");
        LogStringFormatter = LogStringFormatter.replace("{INFO}", info);

        // tekkitrestrict.log.info(LogStringFormatter);
        LogQueue.add(
            new String[] {
              type,
              TLogLocation + esplitter + type,
              TLogLocation + esplitter + type + "/" + LogNameFormatter,
              LogStringFormatter + "\n"
            });
      }
    }
  }
Example #27
0
 public static void removeAllSummerPeople(HashMap<String, Date> map) {
   Date june = new Date();
   june.setMonth(5);
   Date july = new Date();
   july.setMonth(6);
   Date august = new Date();
   august.setMonth(7);
   Iterator<Map.Entry<String, Date>> iterator = map.entrySet().iterator();
   while (iterator.hasNext()) {
     int month = iterator.next().getValue().getMonth();
     if (month == june.getMonth() || month == july.getMonth() || month == august.getMonth()) {
       iterator.remove();
     }
   }
 }
  public Object[][] procesar_cita(Date fech) {

    int max = puntos.length;

    if (max <= 0) return null;

    int pos_ini; // posicion incial de la fecha requerida
    int pos_fin = 0;
    int aaaaaja = -1;
    for (pos_ini = 0; pos_ini < max; pos_ini++) {

      if (puntos[pos_ini].getDate() == fech.getDate()) {
        if (puntos[pos_ini].getMonth() == fech.getMonth()) {
          if (puntos[pos_ini].getYear() == fech.getYear()) {
            aaaaaja = 1;
            break; // cortar la iteracion
          }
        }
      }
    }

    if (aaaaaja != 1) // no consiguio la fecha
    return null;

    for (pos_fin = pos_ini; pos_fin < max; pos_fin++) {

      if ((puntos[pos_fin].getDate() != fech.getDate())
          || (puntos[pos_fin].getMonth() != fech.getMonth())
          || (puntos[pos_fin].getYear() != fech.getYear())) {
        break;
      }
    }
    pos_fin--;

    pos_ini = Diccionario[pos_ini];
    pos_fin = Diccionario[pos_fin];

    Object[][] aux = new Object[pos_fin - pos_ini + 1][col];

    for (int i = 0; i <= pos_fin - pos_ini; i++) {
      for (int j = 0; j < col; j++) {
        // System.out.println("NO JODAS "+" QUE LADILLA "+(pos_ini+i));
        aux[i][j] = tuplas[pos_ini + i][j];
      }
    }

    return aux;
  }
 public static String agregarGasto(
     Date fecha,
     int tipoDoc,
     String numDoc,
     String descripcion,
     float montoTotal,
     ArrayList<InsumoAlmacen> insumos,
     String ruc) {
   int numDocumento;
   try {
     numDocumento = Integer.parseInt(numDoc);
   } catch (Exception e) {
     return "Error: El numero de documento solo puede contener numeros";
   }
   Gastos g = new Gastos(0, fecha.getDay(), fecha.getMonth(), fecha.getYear(), montoTotal);
   g.setGasDes("Pago por insumos");
   g.setGasNumDoc(numDocumento);
   g.setGasNBol(numDocumento);
   g.setTipDocCod(new TipoDocumento(tipoDoc));
   g.setEmpDni(new Empleado(Integer.parseInt(ManejoSesion.getDNI())));
   g.setProvRuc(new Proveedor(ruc));
   g.setTipGasCod(new TipoGasto(1));
   if (new GestionarGastosImplementacion().agregarGasto(g)) {
     for (InsumoAlmacen ins : insumos) {
       IngresoKardexControlador.agregarIngresoKardex(
           g.getGasCod(), ins.getCodInsumo(), ins.getCantidad(), ins.getPrecio());
     }
     return "CORRECTO";
   } else {
     return "No se pudo agregar el gasto";
   }
 }
 public static String agregarGasto(
     int tipo, Date fecha, int tipoDoc, String numDoc, String descripcion, String monto) {
   float montoTotal;
   int numDocumento;
   try {
     montoTotal = Float.parseFloat(monto);
   } catch (Exception e) {
     return "Ingrese un monto valido";
   }
   try {
     numDocumento = Integer.parseInt(numDoc);
   } catch (Exception e) {
     return "El numero de documento solo puede contener numeros";
   }
   if (ValidacionGeneral.precioValido(montoTotal)) {
     Gastos g = new Gastos(1, fecha.getDay(), fecha.getMonth(), fecha.getYear(), montoTotal);
     g.setGasNumDoc(numDocumento);
     g.setTipDocCod(new TipoDocumento(tipoDoc));
     g.setEmpDni(new Empleado(Integer.parseInt(ManejoSesion.getDNI())));
     g.setProvRuc(new Proveedor("00000000001"));
     g.setTipGasCod(new TipoGasto(tipo));
     new GestionarGastosImplementacion().agregarGasto(g);
     return "CORRECTO";
   } else {
     return "Ingrese un monto valido";
   }
 }