Exemplo n.º 1
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;
 }
  /** Set up the environment. */
  @BeforeClass(alwaysRun = true)
  public void setEnvironment() throws Exception {

    init("tsheets-connector-1.0.0");

    esbRequestHeadersMap.put("Accept-Charset", "UTF-8");
    esbRequestHeadersMap.put("Content-Type", "application/json");

    apiRequestHeadersMap.putAll(esbRequestHeadersMap);
    apiRequestHeadersMap.put(
        "Authorization", "Bearer " + connectorProperties.getProperty("accessToken"));

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    Date date = new Date();
    date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").parse(sdf.format(date));
    date.setDate(date.getDate() - 1);
    String timeSheetTwoEnd = sdf.format(date) + "-07:00";
    date.setMinutes(date.getMinutes() - 1);
    String timeSheetTwoStart = sdf.format(date) + "-07:00";
    date.setDate(date.getDate() - 1);
    String timeSheetOneEnd = sdf.format(date) + "-07:00";
    date.setMinutes(date.getMinutes() - 1);
    String timeSheetOneStart = sdf.format(date) + "-07:00";
    connectorProperties.setProperty("timeSheetOneStart", timeSheetOneStart);
    connectorProperties.setProperty("timeSheetOneEnd", timeSheetOneEnd);
    connectorProperties.setProperty("timeSheetTwoStart", timeSheetTwoStart);
    connectorProperties.setProperty("timeSheetTwoEnd", timeSheetTwoEnd);
  }
Exemplo n.º 3
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;
  }
Exemplo n.º 4
0
  public boolean ValidaDatas() {
    try {

      if ((data1.getDate() - data2.getDate()) > 0) {
        JOptionPane.showMessageDialog(
            this, "Data inicial maior que a data final, ou data final menor que a inicial");
        return false;
      }

    } catch (Exception e) {
    }

    if (JdcInicio.getDate() == null) {
      JOptionPane.showMessageDialog(this, "Informe a data Inicial");

      return false;
    }
    if (JdcFim.getDate() == null) {
      JOptionPane.showMessageDialog(this, "Informe a data Final");

      return false;
    }

    return true;
  }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
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();
  }
Exemplo n.º 7
0
 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);
   }
 }
Exemplo n.º 8
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);
   }
 }
Exemplo n.º 9
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 "";
  }
Exemplo n.º 10
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;
  }
Exemplo n.º 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;
 }
  /**
   * Compare date year.
   *
   * @param userBirthDate the user birth date
   * @param dbPatientBirthDate the db patient birth date
   * @return true, if successful
   */
  private boolean compareDateYear(Date userBirthDate, Date dbPatientBirthDate) {
    boolean flag = false;
    if ((userBirthDate.getDate() == dbPatientBirthDate.getDate()
        && userBirthDate.getYear() == dbPatientBirthDate.getYear())) {

      flag = true;
    }
    return flag;
  }
Exemplo n.º 13
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;
 }
Exemplo n.º 14
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;
 }
Exemplo n.º 15
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);
 }
Exemplo n.º 16
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();
  }
Exemplo n.º 17
0
  public static void main(String[] s) {
    ImmutableDate id = new ImmutableDate();
    System.out.println(id.getDate().getDate());
    id.getDate().setDate(11);
    System.out.println(id.getDate().getDate());

    Date td = new Date();
    System.out.println(td.getDate());
    td.setDate(11);
    System.out.println(td.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;
  }
Exemplo n.º 19
0
 public static String makeShortDate(String todaysDate) {
   Date d = StringToDate(todaysDate);
   int month = d.getMonth() + 1;
   todaysDate =
       String.valueOf(d.getYear() + 1900)
           + "-"
           + (month < 10 ? "0" + month : String.valueOf(month))
           + "-"
           + (d.getDate() < 10 ? "0" + d.getDate() : String.valueOf(d.getDate()));
   return todaysDate;
 }
Exemplo n.º 20
0
  // date methods are not deprecated in GWT
  @SuppressWarnings("deprecation")
  private long calculateStartFromMinute(long startFromMinutes, Date from, Date to, int dayOffset) {
    boolean eventStartAtDifferentDay = from.getDate() != to.getDate();
    if (eventStartAtDifferentDay) {
      long minutesOnPrevDay =
          (getTargetDateByCurrentPosition(dayOffset).getTime() - from.getTime())
              / DateConstants.MINUTEINMILLIS;
      startFromMinutes = -1 * minutesOnPrevDay;
    }

    return startFromMinutes;
  }
Exemplo n.º 21
0
  @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());
 }
Exemplo n.º 23
0
  @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"
            });
      }
    }
  }
Exemplo n.º 24
0
  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;
  }
Exemplo n.º 25
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);
  }
Exemplo n.º 26
0
  /** 结束时间 */
  @Click(R.id.tv_endtime)
  void onJssjClick() {
    if (!startimeText.getText().toString().equals("起始时间")) {
      Date dt =
          new Date(DateUtil.strToTimestamp(startimeText.getText().toString(), "yyyy-MM-dd") * 1000);
      if (!endtimeText.getText().toString().equals("结束时间")) {
        dt =
            new Date(
                DateUtil.strToTimestamp(endtimeText.getText().toString(), "yyyy-MM-dd") * 1000);
      }
      datePickerDialog =
          new KooniaoDatePickerDialog(
              ProductEditActivity.this,
              new DatePickerDialog.OnDateSetListener() {

                @Override
                public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                  String timeString = year + "-" + (monthOfYear + 1) + "-" + dayOfMonth;
                  endtimeText.setText(timeString);
                }
              },
              dt.getYear() + 1900,
              dt.getMonth(),
              dt.getDate());
      datePickerDialog.getDatePicker().setMinDate(ApiCaller.TimeInService * 1000);
      datePickerDialog.show();
    } else {
      showToast("请您选择自动上架的起始时间!");
    }
  }
Exemplo n.º 27
0
    public void setBirthday(String birthday) {
      this.birthday = birthday;
      if (this.birthday != null && !this.birthday.equals("")) {
        String tempstr = this.birthday;
        int year = new Date().getYear() + 1900;

        if (tempstr.indexOf(",") == -1) {
          tempstr = tempstr + "," + year;
        } else {
          tempstr = tempstr.substring(0, tempstr.indexOf(",")) + "," + year;
        }

        SimpleDateFormat df = new SimpleDateFormat("MMMM dd,yyyy", Locale.US);
        try {
          Date tempDate = df.parse(tempstr);
          b_month = tempDate.getMonth();
          b_date = tempDate.getDate();
          this.bd_date = tempDate.getTime();
          long distance = System.currentTimeMillis() - bd_date;
          if (distance >= 7 * 24 * 60 * 60 * 1000L) {
            Date dd = new Date(bd_date);
            dd.setYear(dd.getYear() + 1 + 1900);
            bd_date = dd.getTime();
          }
        } catch (ParseException e) {
          this.bd_date = 0;
        }
      }
    }
Exemplo n.º 28
0
 @OptionsItem(R.id.planning_next_week)
 boolean nextWeek() {
   date.setDate(date.getDate() + 7);
   setWeek(date);
   getRepas();
   return true;
 }
Exemplo n.º 29
0
 public final void setDateAsArray(String key, Date value) {
   JsArrayInteger jsArray = JavaScriptObject.createArray().cast();
   jsArray.set(0, value.getYear());
   jsArray.set(1, value.getMonth());
   jsArray.set(2, value.getDate());
   set(key, jsArray);
 };
Exemplo n.º 30
0
  public void addScoutsToClazz(Key<Clazz> clazzKey, List<Key<Scout>> scoutList) {
    Objectify ofy = ObjectifyService.begin();
    Clazz c = get(clazzKey);

    if (c == null) {
      throw new RuntimeException("Clazz " + clazzKey.getId() + " not found!");
    }

    Event e = ofy.get(c.getEvent());
    for (Key<Scout> scoutId : scoutList) {
      if (!c.getScoutIds().contains(scoutId)) {
        c.getScoutIds().add(scoutId);
      }
    }
    for (Key<Scout> s : scoutList) {
      TrackProgress tp = new TrackProgress();
      tp.setScoutKey(s);
      tp.setClazzKey(clazzKey);
      Date curDate = (Date) e.getStartDate().clone();
      List<DateAttendance> attendanceList = new ArrayList<DateAttendance>();
      while (!curDate.after(e.getEndDate())) {
        DateAttendance da = new DateAttendance();
        da.setDate((Date) curDate.clone());
        da.setPresent(false);
        curDate.setDate(curDate.getDate() + 1);
        attendanceList.add(da);
      }
      tp.setAttendanceList(attendanceList);
      MeritBadge mb = ofy.get(c.getMbId());
      tp.setRequirementList(buildRequirementList(mb.getRequirements(), "", 0));
      ofy.put(tp);
    }

    ofy.put(c);
  }