示例#1
0
  public static void main(String[] args) {
    String dayStrBegin = "2016-03-14";
    String dayStrEnd = "2016-03-20";

    String datePattern = "yyyy-MM-dd";
    DateTimeFormatter dateFormatter = DateTimeFormat.forPattern(datePattern);

    LocalDate localDateStart = dateFormatter.parseLocalDate(dayStrBegin);
    LocalDate localDateEnd = dateFormatter.parseLocalDate(dayStrEnd);

    // 比较大小,不返回相差的天数
    // localDateStart.compareTo(localDateEnd);

    // 减去一个Period,不能应用于localDateEnd
    // localDateStart.minus(ReadablePeriod);

    // minus的入参是ReadablePeriod
    // Duration ninetyDays = new Duration(NINETY_DAYS_MILLI);

    /*
     * Period ninetyDays = new Period(NINETY_DAYS_MILLI); LocalDate limitStart = localDateEnd.minus(ninetyDays); if
     * (localDateStart.compareTo(limitStart) != -1) { System.out.println("Hi, there"); }
     */

    Days durationDays = Days.daysBetween(localDateStart, localDateEnd);
    if (durationDays.getDays() <= 90) {
      System.out.println("Hi, there");
    }
  }
 @Override
 public LocalDate read(JsonReader in) throws IOException {
   switch (in.peek()) {
     case NULL:
       in.nextNull();
       return null;
     default:
       String date = in.nextString();
       return formatter.parseLocalDate(date);
   }
 }
示例#3
0
  // Construct a new Transaction using a JSON object from the server
  public Transaction(JSONObject obj) {
    try {
      enabled = true;
      name = obj.getString("name");
      category = obj.getString("category");
      amount = obj.getDouble("amount");

      if (obj.getString("type").equals("deposit")) {
        type = TransactionType.DEPOSIT;
      } else {
        type = TransactionType.WITHDRAWAL;
      }

      DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd");
      insDate = fmt.parseLocalDate(obj.getString("effectiveDate"));
      effDate = fmt.parseLocalDate(obj.getString("creationDate"));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  @Override
  public void generateIvrAndSmsStatisticReports() {
    Config config = configService.getConfig();

    if (StringUtils.isNotBlank(config.getLastCalculationDateForIvrReports())) {
      LocalDate startDate =
          SIMPLE_DATE_FORMATTER.parseLocalDate(config.getLastCalculationDateForIvrReports());
      generateIvrAndSmsStatisticReportsFromDate(startDate);
    } else {
      generateIvrAndSmsStatisticReportsFromDate(null);
    }

    config = configService.getConfig();
    config.setLastCalculationDateForIvrReports(LocalDate.now().toString(SIMPLE_DATE_FORMATTER));
    configService.updateConfig(config);
  }
  @POST
  @Path("/documents")
  @Consumes({MediaType.MULTIPART_FORM_DATA})
  @Produces({MediaType.APPLICATION_JSON})
  public Response createUploadFile(
      @HeaderParam("Content-Length") final Long fileSize,
      @FormDataParam("file") final InputStream inputStream,
      @FormDataParam("file") final FormDataContentDisposition fileDetails,
      @FormDataParam("file") final FormDataBodyPart bodyPart,
      @FormDataParam("status") final String name,
      @FormDataParam("description") final String description) {

    FileUtils.validateFileSizeWithinPermissibleRange(
        fileSize, name, ApiConstants.MAX_FILE_UPLOAD_SIZE_IN_MB);
    inputStreamObject = inputStream;
    DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
    final Date date = DateUtils.getDateOfTenant();
    final DateTimeFormatter dtf = DateTimeFormat.forPattern("dd MMMM yyyy");
    final LocalDate localdate = dtf.parseLocalDate(dateFormat.format(date));
    final String fileUploadLocation = FileUtils.generateXlsFileDirectory();
    final String fileName = fileDetails.getFileName();
    if (!new File(fileUploadLocation).isDirectory()) {
      new File(fileUploadLocation).mkdirs();
    }
    final DataUploadCommand uploadStatusCommand =
        new DataUploadCommand(
            name,
            null,
            localdate,
            "",
            null,
            null,
            null,
            description,
            fileName,
            inputStream,
            fileUploadLocation);
    CommandProcessingResult id = this.dataUploadWritePlatformService.addItem(uploadStatusCommand);
    return Response.ok().entity(id.toString()).build();
    // return null;
  }