private List<CustomDate> createData() {
   dataList = new ArrayList<CustomDate>();
   for (int i = 0; i < DATE_LENGTH; i++) {
     dataList.add(new CustomDate(DateUtil.getYear(), DateUtil.getMonth() + (i - DATE_LENGTH / 2)));
   }
   return dataList;
 }
Esempio n. 2
0
 @Test
 public void testDateStr() {
   Date date = DateUtil.now().get();
   Integer time = new Long(date.getTime()).intValue();
   System.out.println(DateUtil.formatDateTime(date));
   System.out.println(date.getTime() + ":" + time + ":" + Integer.toHexString(time).toUpperCase());
 }
 private List<NextEventsDate> getNextEvents(boolean fetchOnlyImportant, String... almanachIds) {
   List<NextEventsDate> result = new ArrayList<NextEventsDate>();
   try {
     List<EventOccurrence> events = getAlmanachBm().getNextEventOccurrences(almanachIds);
     Date today = new Date();
     Date date = null;
     NextEventsDate nextEventsDate = null;
     for (EventOccurrence event : events) {
       if (Administration.get()
           .isComponentAvailable(event.getEventDetail().getInstanceId(), getUserId())) {
         if (!fetchOnlyImportant || (fetchOnlyImportant && event.isPriority())) {
           Date eventDate = event.getStartDate().asDate();
           if (DateUtil.compareTo(today, eventDate, true) != 0) {
             if (date == null || DateUtil.compareTo(date, eventDate, true) != 0) {
               nextEventsDate = new NextEventsDate(eventDate);
               result.add(nextEventsDate);
               date = eventDate;
             }
             nextEventsDate.addEvent(event);
           }
         }
       }
     }
   } catch (Exception e) {
     SilverTrace.error("lookAurora", "LookAuroraHelper.getNextEvents", "", e);
   }
   return result;
 }
 /**
  * 画面要素へのデータセット
  *
  * @param savedInstanceState バンドル
  */
 private void setViewElement(Bundle savedInstanceState) {
   Log.d("DEBUG", "Search setViewElement Start");
   // 指定年月日を取得
   Calendar clTargetDate;
   if (savedInstanceState != null) {
     // 復元情報から取得
     clTargetDate =
         DateUtil.toCalendar(savedInstanceState.getString("calym") + DateUtil.FIRST_DAY);
   } else {
     clTargetDate = DateUtil.toCalendar(stdObj.getStrCalendarYearMonth() + DateUtil.FIRST_DAY);
   }
   // 対象年月日のTextViewの初期値設定
   tvTargetDate.setText(DateUtil.YEARMONTH_FORMAT.format(clTargetDate.getTime()));
   // マイク機能が使用可能か確認し、使用不可能な場合、非表示とする
   boolean blHasMicFeature =
       getPackageManager().hasSystemFeature(PackageManager.FEATURE_MICROPHONE);
   if (blHasMicFeature) {
     // マイク機能が使用可能な場合
     ivMicIcon1.setVisibility(View.VISIBLE);
     Log.d("DEBUG", "Search setViewElement FEATURE_MICROPHONE:OK");
   } else {
     // マイク機能が使用不可能な場合
     ivMicIcon1.setVisibility(View.INVISIBLE);
     Log.d("DEBUG", "Search setViewElement FEATURE_MICROPHONE:OUT");
   }
   Log.d("DEBUG", "Search setViewElement End");
 }
  public static void main(String[] args) {
    int op = -1;
    RepositorioPacientes repositorioPacientes = new RepositorioPacientes();

    do {
      System.out.println("Menu: ");
      System.out.println("1- Cadastrar Paciente");
      System.out.println("2- Listar Pacientes");
      System.out.println("3- Sair da Aplicação");

      try {
        op = Console.scanInt("Digite a opção do menu: ");

        switch (op) {
          case 1:
            try {
              System.out.println("\nCadastro de Pacientes");
              String rg = Console.scanString("RG: ");
              String nome = Console.scanString("Nome: ");
              String dataString = Console.scanString("Nascimento (dia/mes/ano): ");
              Date dataNasc = DateUtil.stringToDate(dataString);
              Paciente paciente = new Paciente(rg, nome, dataNasc);
              repositorioPacientes.adicionar(paciente);
            } catch (ParseException ex) {
              System.out.println("Formato de data errado! Operação cancelada!");
            }

            break;

          case 2:
            System.out.println("\nLista de pacientes");
            if (!repositorioPacientes.temPacientes()) {
              System.out.println("Nenhum paciente foi cadastrado!");
            } else {
              System.out.print(String.format("%-10s", "RG"));
              System.out.print(String.format("%-20s", "NOME"));
              System.out.println(String.format("%-10s", "NASCIMENTO"));
              for (Paciente p : repositorioPacientes.getListaPacientes()) {
                System.out.print(String.format("%-10s", p.getRg()));
                System.out.print(String.format("%-20s", p.getNome()));
                System.out.println(
                    String.format("%-10s", DateUtil.dateToString(p.getDataNascimento())));
              }
            }

            break;
          case 3:
            System.out.println("Saindo da aplicação...");
            break;
          default:
            System.out.println("Opção Inválida!");
        }
      } catch (InputMismatchException ime) {
        System.out.println("Opção Inválida! Não pode digitar letras!");
      }

    } while (op != 3);
  }
  @Override
  public void onClick(View v) {

    if (v == yes) {
      if (validate()) {
        if (repeatRepRadio.isChecked()) {
          rule.setCount(Integer.parseInt(repeatRepEdit.getText().toString()));
          rule.setUntil(null);
        } else {
          rule.setCount(null);
          rule.setUntil(DateUtil.convertDateToRRULE(repeatUntilDate.getText().toString()));
        }

        dismiss();
      }

    } else if (v == no) {
      cancelClicked = true;
      cancel();
    } else if (v == repeatRepEdit || v == repeatRepRadio || v == repeatRepRow) {

      repeatUntilRadio.setChecked(false);
      repeatRepRadio.setChecked(true);
      repeatRepEdit.setEnabled(true);
      repeatRepEdit.setFocusable(true);
      previousSelectedRadio = repeatRepRadio;

    } else if (v == repeatUntilDate || v == repeatUntilRadio || v == repeatUntilRow) {
      repeatRepRadio.setChecked(false);
      repeatUntilRadio.setChecked(true);
      repeatRepEdit.setEnabled(false);
      DatePickerDialog dialog = null;
      if (!StringUtils.isEmpty(repeatUntilDate.getText().toString())) {
        GregorianCalendar cal =
            DateUtil.getCalendarFromString(repeatUntilDate.getText().toString());
        dialog =
            new DatePickerDialog(
                activity,
                datePickerListener,
                cal.get(Calendar.YEAR),
                cal.get(Calendar.MONTH),
                cal.get(Calendar.DAY_OF_MONTH));
      } else {
        dialog =
            new DatePickerDialog(
                activity,
                datePickerListener,
                eventDate.get(Calendar.YEAR),
                eventDate.get(Calendar.MONTH),
                eventDate.get(Calendar.DAY_OF_MONTH));
      }

      dialog.setOnDismissListener(datePickerDismissListener);

      dialog.show();
    }
  }
 /** @see {@link DateRange#isAfter(DateRange,Date)} */
 @Test
 @Verifies(
     value = "should return true if the passed date is after the date range",
     method = "isAfter(DateRange,Date)")
 public void isAfter_shouldReturnTrueIfThePassedDateIsAfterTheDateRange() throws Exception {
   DateRange dr = DateRange.parse("[2007-01-01,2008-01-01)", "yyyy-MM-dd", "*");
   Assert.assertTrue(DateRange.isAfter(dr, DateUtil.getDateTime(2008, 1, 1)));
   Assert.assertTrue(DateRange.isAfter(dr, DateUtil.getDateTime(2008, 1, 2)));
 }
 /** @see {@link DateRange#isWithin(DateRange,Date)} */
 @Test
 @Verifies(
     value = "should return false if the passed date is before the date range",
     method = "isWithin(DateRange,Date)")
 public void isWithin_shouldReturnFalseIfThePassedDateIsBeforeTheDateRange() throws Exception {
   DateRange dr = DateRange.parse("(2007-01-01,2008-01-01)", "yyyy-MM-dd", "*");
   Assert.assertFalse(DateRange.isWithin(dr, DateUtil.getDateTime(2007, 1, 1)));
   Assert.assertFalse(DateRange.isWithin(dr, DateUtil.getDateTime(2006, 1, 1)));
 }
Esempio n. 9
0
 /**
  * Create a new persistence item information.
  *
  * @param name the item name
  * @param count the number of entries
  * @param earliest the date of the first entry (may be null)
  * @param latest the date of the last entry (may be null)
  */
 public PersistenceItemInfoImpl(
     final @NonNull String name,
     final @NonNull Integer count,
     final @Nullable Date earliest,
     final @Nullable Date latest) {
   this.name = name;
   this.count = count;
   this.earliest = DateUtil.clone(earliest);
   this.latest = DateUtil.clone(latest);
 }
  /** @see {@link DateRange#format(DateRange,String,String)} */
  @Test
  @Verifies(
      value = "should return the passed date range formatted in interval notation",
      method = "format(DateRange,String,String)")
  public void format_shouldReturnThePassedDateRangeFormattedInIntervalNotation() throws Exception {
    DateRange dr1 =
        new DateRange(
            DateUtil.getDateTime(2007, 10, 1), true, DateUtil.getDateTime(2008, 11, 20), true);
    Assert.assertEquals("[2007-10-01,2008-11-20]", DateRange.format(dr1, "yyyy-MM-dd", "*"));

    DateRange dr2 = new DateRange(DateUtil.getDateTime(2007, 10, 1), false, null, false);
    Assert.assertEquals("(10/01/2007,*)", DateRange.format(dr2, "MM/dd/yyyy", "*"));
  }
Esempio n. 11
0
 public void run() {
   Logger.println("Version " + Version.getAgentFullVersion());
   long dateUnit = DateUtil.getDateUnit();
   while (running) {
     reload(false);
     // Text Data Reset..
     long nowUnit = DateUtil.getDateUnit();
     if (dateUnit != nowUnit) {
       dateUnit = nowUnit;
       DataProxy.reset();
     }
     ThreadUtil.sleep(3000);
   }
 }
Esempio n. 12
0
  /**
   * Build the string for sending resize events to server
   *
   * @param event
   * @return
   */
  private String buildResizeString(CalendarEvent event) {
    StringBuilder buffer = new StringBuilder();
    buffer.append(event.getIndex());
    buffer.append(",");
    buffer.append(DateUtil.formatClientSideDate(event.getStart()));
    buffer.append("-");
    buffer.append(DateUtil.formatClientSideTime(event.getStartTime()));
    buffer.append(",");
    buffer.append(DateUtil.formatClientSideDate(event.getEnd()));
    buffer.append("-");
    buffer.append(DateUtil.formatClientSideTime(event.getEndTime()));

    return buffer.toString();
  }
Esempio n. 13
0
  /**
   * Convert a date to a String and a String to a Date
   *
   * @param type String, Date or Timestamp
   * @param value value to convert
   * @return Converted value for property population
   */
  public Object convert(Class type, Object value) {
    if (value == null) {
      return null;
    } else if (type == Timestamp.class) {
      return convertToDate(type, value, DateUtil.getDateTimePattern());
    } else if (type == Date.class) {
      return convertToDate(type, value, DateUtil.getDatePattern());
    } else if (type == String.class) {
      return convertToString(type, value);
    }

    throw new ConversionException(
        "Could not convert " + value.getClass().getName() + " to " + type.getName());
  }
  public static void main(String[] args) {
    PriorityQueue<Student> studenten = new PriorityQueue();

    Student s1 = new Student(1, DateUtil.getDateInstance(1978, 3, 18));
    Student s2 = new Student(2, DateUtil.getDateInstance(1962, 1, 24));
    Student s3 = new Student(3, DateUtil.getDateInstance(1978, 5, 31));

    studenten.add(s1);
    studenten.add(s2);
    studenten.add(s3);

    System.out.println(studenten.poll().getGeboorteDatum());
    System.out.println(studenten.poll().getGeboorteDatum());
    System.out.println(studenten.poll().getGeboorteDatum());
  }
  /**
   * Calculates the postpartum end date as 6 months past the delivery date.
   *
   * <p>NOTE: In the absence of a delivery date, the EDC is used.
   *
   * @return The end date of the postpartum stage
   */
  public Date getPostpartumStageEndDate() {
    Date deliveryDate = null;
    if (Functions.observation(mcProgramObs.getObs(), MCDeliveryReportConcepts.DELIVERY_REPORT)
        != null) {
      final Obs deliveryDateObs =
          mcProgramObs.getDeliveryReport().getMember(MCDeliveryReportConcepts.DELIVERY_DATE);
      if (deliveryDateObs != null) {
        deliveryDate = deliveryDateObs.getValueDatetime();
      }
    }

    if (deliveryDate == null) {
      // use EDC
      deliveryDate = mcProgramObs.getEstimatedDateOfConfinement();
    }

    if (deliveryDate != null) {
      final Calendar sixMonthsAfterDeliveryDate = Calendar.getInstance();
      sixMonthsAfterDeliveryDate.setTime(DateUtil.stripTime(deliveryDate));
      sixMonthsAfterDeliveryDate.add(Calendar.MONTH, 6);

      // return the calculated postpartum stage end date
      return sixMonthsAfterDeliveryDate.getTime();
    }

    // postpartum stage end date is not available
    return null;
  }
Esempio n. 16
0
 public void testParse() {
   Calendar c1 = Calendar.getInstance();
   c1.set(2012, 5 - 1, 1, 0, 0, 0);
   c1.set(Calendar.MILLISECOND, 0);
   Date date = c1.getTime();
   assertEquals(date, DateUtil.parse("2012-05-01"));
 }
Esempio n. 17
0
  @Test
  public void testCreateAuthorizationHeader() {
    Date now = DateUtil.now();

    String method = "POST";
    String hostname = "api.tuppari.com";
    String path = "/test";
    String query = "a=v1&b=v2";

    Map<String, String> headers = new HashMap<String, String>();
    headers.put("Host", "api.tuppari.com");
    headers.put("Content-type", "application/json");
    headers.put("X-Tuppari-Operation", "CreateApplication");

    Map<String, Object> body = new LinkedHashMap<String, Object>();
    body.put("applicationName", "example1");
    String accessKeyId = "accessKeyId";
    String accessSecretKey = "accessSecretKey";

    String authorization =
        SignUtil.createAuthorizationHeader(
            method, hostname, path, query, headers, body, now, accessKeyId, accessSecretKey);
    assertThat(
        authorization,
        is(
            "HMAC-SHA256 Credential=accessKeyId,SignedHeaders=content-type;host;x-tuppari-operation,Signature=050f8711271747d4f63a3caa3ffb420e4cd5a0e9d9dda8ba7e4faad6794c40d0"));
  }
  /**
   * Handles the Time.now macro
   *
   * @param tokens list of tokens
   * @param iter iterator used to iterate over the list of tokens
   * @return string containing the interpolated time token
   */
  private static String handleTime(List<String> tokens, Iterator<String> iter) {
    DateTime dt = new DateTime();

    // Add some amount
    if (iter.hasNext()) {
      String operationToken = iter.next();
      if (operationToken.equals("+") || operationToken.equals("-")) {
        if (iter.hasNext()) {
          String quantityToken = iter.next(); // Get the magnitude to
          // add or subtract

          ReadablePeriod period = getTimePeriod(quantityToken);

          if (operationToken.equals("-")) {
            dt = dt.minus(period);
          } else {
            dt = dt.plus(period);
          }
        } else {
          logger.warn("Token '{}' not followed by a quantity", operationToken);
        }
      } else {
        logger.warn("Invalid token '{}', must be operator '+' or '-'", operationToken);
      }
    }

    return DATE_UTIL.formatDateTime(dt);
  }
  private void _testGetDaysBetween(Date date1, Date date2, int expected) {
    mockStatic(CalendarFactoryUtil.class);

    when(CalendarFactoryUtil.getCalendar()).thenReturn(new GregorianCalendar());

    Assert.assertEquals(expected, DateUtil.getDaysBetween(date1, date2, _timeZone));
  }
 /**
  * ToDo情報のデータベース検索処理
  *
  * @strSearchWord 検索ワード
  * @return 処理を行った場合はtrue
  */
 private boolean searchTODO(String strSearchWord) {
   Log.d("DEBUG", "Search SetSearchResultListTask searchTODO Start");
   boolean blResult = true;
   ToDoCursor tdcObj = null;
   lSLR = new ArrayList<SearchListRow>();
   try {
     String[] where_args = {strSearchWord, strSearchWord};
     // カーソルの取得
     tdcObj = tdhDB.getToDoSearchResult(where_args);
     // カーソルポインター初期化
     startManagingCursor(tdcObj);
     Log.d(
         "DEBUG",
         "Search SetSearchResultListTask searchTODO ScheduleCursor Count : "
             + tdcObj.getCount());
     for (int intCt = 0; intCt < tdcObj.getCount(); intCt++) {
       // スケジュールのセット
       SearchListRow slrObj = new SearchListRow();
       slrObj.setStrDate(DateUtil.convBaseYMD(tdcObj.getColDate()));
       slrObj.setStrSearchType(getString(R.string.tdsearchtarget));
       lSLR.add(slrObj);
       tdcObj.moveToNext();
     }
     tdcObj.close();
   } catch (SQLException e) {
     blResult = false;
     Log.e("ERROR", "Search SetSearchResultListTask searchTODO DB Error", e);
   } finally {
     if (tdcObj != null) {
       tdcObj.close();
     }
   }
   Log.d("DEBUG", "Search SetSearchResultListTask searchTODO End");
   return blResult;
 }
 /**
  * 入力値チェック処理
  *
  * @return 処理を行った場合はtrue
  */
 private boolean checkInputSearch(boolean blSearchType) {
   Log.d("DEBUG", "Search checkInputSchedule Start");
   boolean blResult = true;
   StringBuilder sbObj = new StringBuilder();
   // 検索対象文字列エディットテキスト
   String strSearchWord = etSearchString.getText().toString();
   if (strSearchWord == null || strSearchWord.equals("")) {
     // 空(null)チェック
     blResult = false;
     sbObj.append(getString(R.string.sestring_msg) + getString(R.string.restoreConfirm1));
   }
   // ToDo検索時
   if (blSearchType) {
     // 開始年月日ビュー
     String strTargetDate = tvTargetDate.getText().toString();
     if (strTargetDate == null || strTargetDate.equals("")) {
       // 空(null)チェック
       blResult = false;
       sbObj.append(getString(R.string.setargetperiod_msg) + getString(R.string.restoreConfirm1));
     } else {
       // YYYY-MM形式チェック
       if (DateUtil.checkYMFormat(strTargetDate) == false) {
         blResult = false;
         sbObj.append(
             getString(R.string.setargetperiod_errmsg1) + getString(R.string.restoreConfirm1));
       }
     }
   }
   if (blResult == false) {
     showDialog(this, "", sbObj.toString(), getString(R.string.yes_btn));
   }
   Log.d("DEBUG", "Search checkInputSchedule End");
   return blResult;
 }
 /**
  * tdSearch ToDo検索ボタン押下時の処理
  *
  * @param v 選択ビュー
  */
 public void tdSearch(View view) {
   Log.d("DEBUG", "Search tdSearch Start");
   if (blSearch == true) {
     // 検索ボタン連打ロックオン
     blSearch = false;
     // 入力値チェック
     boolean blCheckInput = checkInputSearch(true);
     if (blCheckInput == true) {
       // 検索文字列取得
       String strSearchWord = etSearchString.getText().toString();
       // 選択対象年月情報取得
       GregorianCalendar gcObj =
           DateUtil.toCalendar(tvTargetDate.getText().toString() + DateUtil.FIRST_DAY);
       StringBuilder sbDateText = new StringBuilder();
       sbDateText.append(Integer.toString(gcObj.get(Calendar.YEAR)));
       sbDateText.append(Integer.toString(gcObj.get(Calendar.MONTH) + 1));
       // 検索処理
       SetSearchResultListTask task = new SetSearchResultListTask();
       task.execute(sbDateText.toString(), strSearchWord);
     } else {
       // 検索ボタン連打ロックオフ
       blSearch = true;
     }
   }
   Log.d("DEBUG", "Search tdSearch End");
 }
Esempio n. 23
0
  @Test
  public void testUpsertDateValues() throws Exception {
    long ts = nextTimestamp();
    Date now = new Date(System.currentTimeMillis());
    ensureTableCreated(getUrl(), TestUtil.PTSDB_NAME, null, ts - 2);
    Properties props = new Properties();
    props.setProperty(
        PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 1)); // Execute at timestamp 1
    Connection conn = DriverManager.getConnection(PHOENIX_JDBC_URL, props);
    String dateString = "1999-01-01 02:00:00";
    PreparedStatement upsertStmt =
        conn.prepareStatement(
            "upsert into ptsdb(inst,host,date) values('aaa','bbb',to_date('" + dateString + "'))");
    int rowsInserted = upsertStmt.executeUpdate();
    assertEquals(1, rowsInserted);
    upsertStmt =
        conn.prepareStatement(
            "upsert into ptsdb(inst,host,date) values('ccc','ddd',current_date())");
    rowsInserted = upsertStmt.executeUpdate();
    assertEquals(1, rowsInserted);
    conn.commit();

    props.setProperty(
        PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 2)); // Execute at timestamp 1
    conn = DriverManager.getConnection(PHOENIX_JDBC_URL, props);
    String select = "SELECT date,current_date() FROM ptsdb";
    ResultSet rs = conn.createStatement().executeQuery(select);
    Date then = new Date(System.currentTimeMillis());
    assertTrue(rs.next());
    Date date = DateUtil.parseDate(dateString);
    assertEquals(date, rs.getDate(1));
    assertTrue(rs.next());
    assertTrue(rs.getDate(1).after(now) && rs.getDate(1).before(then));
    assertFalse(rs.next());
  }
Esempio n. 24
0
 // 获取当前月的第一天
 public static String getFirstDay(String format) {
   Calendar calendar = Calendar.getInstance();
   int month = calendar.get(Calendar.MONTH);
   int year = calendar.get(Calendar.YEAR);
   calendar.set(year, month, 1);
   return DateUtil.getDateText(calendar.getTime(), format);
 }
Esempio n. 25
0
  @Test
  public void testCreateSignedRequestConfig() throws ParseException {
    Date now = DateUtil.now();

    String method = "POST";
    URI uri = URI.create("http://api.tuppari.com/test?a=v1&b=v2");
    String operation = "CreateApplication";
    Map<String, Object> body = new LinkedHashMap<String, Object>();
    body.put("applicationName", "example1");
    String accessKeyId = "accessKeyId";
    String accessSecretKey = "accessSecretKey";

    Map<String, Object> config =
        SignUtil.createSignedRequestConfig(
            method, uri, operation, body, accessKeyId, accessSecretKey);

    assertThat((URI) config.get("uri"), is(uri));
    assertThat((String) config.get("body"), is(JSON.encode(body)));

    Map<String, String> headers = (Map<String, String>) config.get("headers");
    assertThat(headers.get("Host"), is("api.tuppari.com"));
    assertThat(headers.get("Content-Type"), is("application/json"));
    assertThat(headers.get("X-Tuppari-Date"), is("Thu, 01 Jan 1970 00:00:00 GMT"));
    assertThat(headers.get("X-Tuppari-Operation"), is("CreateApplication"));
    assertThat(
        headers.get("Authorization"),
        is(
            "HMAC-SHA256 Credential=accessKeyId,SignedHeaders=content-type;host;x-tuppari-date;x-tuppari-operation,Signature=f35767c9fdba4ba5d5bbbf1c622fceed0dbaeb210303bb56b419c6a51bcf1e5d"));
  }
Esempio n. 26
0
  /**
   * Convert a java.util.Date or a java.sql.Timestamp to a String. Or does a toString
   *
   * @param value value to convert
   * @return Converted value for property population
   */
  protected Object convertToString(final Object value) {
    if (value instanceof Date) {
      DateFormat df = new SimpleDateFormat(DateUtil.getDatePattern());
      if (value instanceof Timestamp) {
        df = new SimpleDateFormat(DateUtil.getDateTimePattern());
      }

      try {
        return df.format(value);
      } catch (final Exception e) {
        throw new ConversionException("Error converting Date to String", e);
      }
    } else {
      return value.toString();
    }
  }
  public static String getTimeStamp() throws Exception {

    Date now = new Date();

    String directoryName = DateUtil.getDateString(now, "yyyyMMddHHmmssSSS", Locale.US);

    return directoryName;
  }
Esempio n. 28
0
 /**
  * 通过天气代号得到天气图片在asserts文件夹中的路径
  *
  * @param weatherCode 天气代号
  * @param timeSensitive 是否根据当前时间选择白天或夜间的图片
  * @return
  */
 public static String getWeatherImagePath(String weatherCode, boolean timeSensitive) {
   return "weather_image"
       + File.separator
       + (!DateUtil.isDay() && timeSensitive ? "night" : "day")
       + File.separator
       + weatherCode
       + ".png";
 }
  public static Date parseStringToDate(String time) {
    Date date = null;
    try {
      date = DateUtil.parseDate(time, "yyyy-MM-dd HH:mm");
    } catch (ParseException e) {

    }
    return date;
  }
Esempio n. 30
0
 private Object getNumericCellValue(final Cell cell) {
   Object cellValue;
   if (DateUtil.isCellDateFormatted(cell)) {
     cellValue = new Date(cell.getDateCellValue().getTime());
   } else {
     cellValue = cell.getNumericCellValue();
   }
   return cellValue;
 }