Ejemplo n.º 1
0
 private void initializebtnDate() {
   Button btnDate = (Button) findViewById(R.id.DateButton);
   String dayOfWeek;
   switch (date.getDay()) {
     case 1:
       dayOfWeek = "Montag";
       break;
     case 2:
       dayOfWeek = "Dienstag";
       break;
     case 3:
       dayOfWeek = "Mittwoch";
       break;
     case 4:
       dayOfWeek = "Donnerstag";
       break;
     case 5:
       dayOfWeek = "Freitag";
       break;
     case 6:
       dayOfWeek = "Samstag";
       break;
     default:
       dayOfWeek = "Sonntag";
       break;
   }
   btnDate.setText(dayOfWeek + ", " + DateFormat.getDateInstance().format(date));
   btnDate.setOnClickListener(
       new OnClickListener() {
         public void onClick(View v) {
           showDialog(0);
         }
       });
 }
  // Author - Shalin Banjara
  // Usage - Business logic to calculate the available timeslots for a particular department based
  // on capacity and day of week.
  public List<DepartmentTimeslotLinkage> timeslotByDepartment(Utility u)
      throws BadSqlGrammarException {
    List<DepartmentTimeslotLinkage> departmenttimeslots =
        new ArrayList<DepartmentTimeslotLinkage>();
    List<DepartmentTimeslotLinkage> finalDepartmenttimeslots =
        new ArrayList<DepartmentTimeslotLinkage>();
    departmenttimeslots = departmentTimeslotMapper.getTimeslotByDepartment(u);
    int i = 0;
    if (departmenttimeslots.size() > 0) {
      for (int j = 0; j < departmenttimeslots.size(); j++) {
        DepartmentTimeslotLinkage depTime = departmenttimeslots.get(j);
        Date d = Date.valueOf(u.getAppointmentDate());
        depTime.setAppointmentDate(d);

        // System.out.println(d.getDay());
        String s = depTime.getWeekdays().substring(d.getDay());

        if (s.startsWith("1")) {
          finalDepartmenttimeslots.add(depTime);
          System.out.println(depTime.toString());
        }
      }
    }
    return finalDepartmenttimeslots;
  }
Ejemplo n.º 3
0
  // 用于显示会话时间
  public String getTime() {
    long currentTime = Configs.getReportTime();
    Date date1 = new Date(currentTime);
    Date date2 = new Date(mTimeStamp);
    SimpleDateFormat format = new SimpleDateFormat("HH:mm");
    SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm ");
    String date = format.format(mTimeStamp);
    int hour = Integer.parseInt(date.substring(0, 2));
    // 今天
    if (date1.getDate() - date2.getDate() == 0) {
      if (hour < 6) return mContext.getString(R.string.before_dawn) + " " + date;
      else if (hour < 12) return mContext.getString(R.string.morning) + " " + date;
      else if (hour < 18) return mContext.getString(R.string.afternoon) + " " + date;
      else return mContext.getString(R.string.night) + " " + date;
      // 昨天
    } else if (date1.getDate() - date2.getDate() == 1) {
      return mContext.getString(R.string.yesterday);
    } else if (date1.getDay() - date2.getDay() > 0) {
      if (date2.getDay() == 1) return mContext.getString(R.string.monday);
      else if (date2.getDay() == 2) return mContext.getString(R.string.tuesday);
      else if (date2.getDay() == 3) return mContext.getString(R.string.wednesday);
      else if (date2.getDay() == 4) return mContext.getString(R.string.thursday);
      else if (date2.getDay() == 5) return mContext.getString(R.string.friday);
      else if (date2.getDay() == 6) return mContext.getString(R.string.saturday);
      else return mContext.getString(R.string.sunday);

    } else if (date1.getYear() == date2.getYear()) {
      return date2.getMonth()
          + 1
          + mContext.getString(R.string.month)
          + date2.getDate()
          + mContext.getString(R.string.day);
    } else return format1.format(mTimeStamp);
  }
Ejemplo n.º 4
0
  @SuppressWarnings("deprecation")
  @Test
  public void date() throws SQLException {
    connectWithJulianDayModeActivated();
    Date d1 = new Date(System.currentTimeMillis());

    stat.execute("create table t (c1);");
    PreparedStatement prep = conn.prepareStatement("insert into t values(?);");
    prep.setDate(1, d1);
    prep.executeUpdate();

    ResultSet rs = stat.executeQuery("select c1 from t;");
    assertTrue(rs.next());
    assertEquals(d1.getYear(), rs.getDate(1).getYear());
    assertEquals(d1.getMonth(), rs.getDate(1).getMonth());
    assertEquals(d1.getDay(), rs.getDate(1).getDay());
    rs.close();
  }