Java 类org.apache.commons.lang.time.DateFormatUtils 实例源码

项目:mumu-pig    文件:NginxLogLoader.java   
@Override
public Tuple getNext() throws IOException {
    try {
        boolean flag = recordReader.nextKeyValue();
        if (!flag) {
            return null;
        }
        Text value = (Text) recordReader.getCurrentValue();
        Map<String, Object> stringObjectMap = NginxAccessLogParser.parseLine(value.toString());
        List propertiyList = new ArrayList<String>();
        propertiyList.add(0, stringObjectMap.get("remoteAddr"));
        propertiyList.add(1, DateFormatUtils.format((Date) stringObjectMap.get("accessTime"), "yyyy-MM-dd HH:mm:ss"));
        propertiyList.add(2, stringObjectMap.get("method"));

        propertiyList.add(3, stringObjectMap.get("url"));
        propertiyList.add(4, stringObjectMap.get("protocol"));
        propertiyList.add(5, stringObjectMap.get("agent"));

        propertiyList.add(6, stringObjectMap.get("refer"));
        propertiyList.add(7, stringObjectMap.get("status"));
        propertiyList.add(8, stringObjectMap.get("length"));
        return TupleFactory.getInstance().newTuple(propertiyList);
    } catch (InterruptedException e) {
        throw new ExecException("Read data error", PigException.REMOTE_ENVIRONMENT, e);
    }
}
项目:mumu-mapreduce    文件:MonthTrafficStatisticsMapReduceTest.java   
@Test
public void mapreduce() {
    MapReduceConfiguration mapReduceConfiguration = new MapReduceConfiguration();
    long start = System.currentTimeMillis();
    log.info("开始计算nginx月访问日志IP统计量");
    try {
        String inputPath = mapReduceConfiguration.url() + "/mapreduce/nginxlog/access/input";
        String outputPath = mapReduceConfiguration.url() + "/mapreduce/nginxlog/access/output/month" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmss");
        MonthTrafficStatisticsMapReduce.main(new String[]{inputPath, outputPath});
        mapReduceConfiguration.print(outputPath);
    } catch (Exception e) {
        log.error(e);
    }
    long end = System.currentTimeMillis();
    log.info("运行mapreduce程序花费时间:" + (end - start) / 1000 + "s");
}
项目:mumu-mapreduce    文件:DailyTrafficStatisticsMapRedTest.java   
@Test
public void mapreduce() {
    MapReduceConfiguration mapReduceConfiguration = new MapReduceConfiguration();
    long start = System.currentTimeMillis();
    log.info("开始计算nginx访问日志IP统计量");
    try {
        String inputPath = mapReduceConfiguration.url() + "/mapreduce/nginxlog/access/input";
        String outputPath = mapReduceConfiguration.url() + "/mapreduce/nginxlog/access/output/daily" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmss");
        ToolRunner.run(new DailyTrafficStatisticsMapRed(), new String[]{inputPath, outputPath});
        mapReduceConfiguration.print(outputPath);
    } catch (Exception e) {
        log.error(e);
    }
    long end = System.currentTimeMillis();
    log.info("运行mapreduce程序花费时间:" + (end - start) / 1000 + "s");
}
项目:mumu-mapreduce    文件:YearTrafficStatisticsMapReduceTest.java   
@Test
public void mapreduce() {
    MapReduceConfiguration mapReduceConfiguration = new MapReduceConfiguration();
    long start = System.currentTimeMillis();
    log.info("开始计算nginx年访问日志IP统计量");
    try {
        String inputPath = mapReduceConfiguration.url() + "/mapreduce/nginxlog/access/input";
        String outputPath = mapReduceConfiguration.url() + "/mapreduce/nginxlog/access/output/year" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmss");
        YearTrafficStatisticsMapReduce.main(new String[]{inputPath, outputPath});
        mapReduceConfiguration.print(outputPath);
    } catch (Exception e) {
        log.error(e);
    }
    long end = System.currentTimeMillis();
    log.info("运行mapreduce程序花费时间:" + (end - start) / 1000 + "s");
}
项目:mumu-mapreduce    文件:MaxTemperatureMapRedTest.java   
@Test
public void mapreduce() {
    MapReduceConfiguration mapReduceConfiguration = new MapReduceConfiguration();
    DistributedFileSystem distributedFileSystem = mapReduceConfiguration.distributedFileSystem();
    try {
        String inputPath = mapReduceConfiguration.url() + "/mapreduce/temperature/input";
        Path inputpath = new Path(inputPath);
        //文件不存在 则将输入文件导入到hdfs中
        if (!distributedFileSystem.exists(inputpath)) {
            distributedFileSystem.mkdirs(inputpath);
            distributedFileSystem.copyFromLocalFile(true, new Path(this.getClass().getClassLoader().getResource("mapred/temperature/input").getPath()), new Path(inputPath + "/input"));
        }
        String outputPath = mapReduceConfiguration.url() + "/mapreduce/temperature/mapred/output" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmSS");

        ToolRunner.run(new MaxTemperatureMapRed(), new String[]{inputPath, outputPath});
        mapReduceConfiguration.print(outputPath);
    } catch (Exception e) {
        log.error(e);
        e.printStackTrace();
    } finally {
        mapReduceConfiguration.close(distributedFileSystem);
    }
}
项目:hadoop    文件:TestYarnCLI.java   
@Test
public void testNodeStatus() throws Exception {
  NodeId nodeId = NodeId.newInstance("host0", 0);
  NodeCLI cli = new NodeCLI();
  when(client.getNodeReports()).thenReturn(
                  getNodeReports(3, NodeState.RUNNING, false));
  cli.setClient(client);
  cli.setSysOutPrintStream(sysOut);
  cli.setSysErrPrintStream(sysErr);
  int result = cli.run(new String[] { "-status", nodeId.toString() });
  assertEquals(0, result);
  verify(client).getNodeReports();
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  PrintWriter pw = new PrintWriter(baos);
  pw.println("Node Report : ");
  pw.println("\tNode-Id : host0:0");
  pw.println("\tRack : rack1");
  pw.println("\tNode-State : RUNNING");
  pw.println("\tNode-Http-Address : host1:8888");
  pw.println("\tLast-Health-Update : "
    + DateFormatUtils.format(new Date(0), "E dd/MMM/yy hh:mm:ss:SSzz"));
  pw.println("\tHealth-Report : ");
  pw.println("\tContainers : 0");
  pw.println("\tMemory-Used : 0MB");
  pw.println("\tMemory-Capacity : 0MB");
  pw.println("\tCPU-Used : 0 vcores");
  pw.println("\tCPU-Capacity : 0 vcores");
  pw.println("\tNode-Labels : a,b,c,x,y,z");
  pw.close();
  String nodeStatusStr = baos.toString("UTF-8");
  verify(sysOut, times(1)).println(isA(String.class));
  verify(sysOut).println(nodeStatusStr);
}
项目:mumu-pig    文件:DateFormatEval.java   
@Override
public String exec(final Tuple tuple) throws IOException {
    if (tuple == null || tuple.size() == 0) {
        return null;
    }
    Object dateString = tuple.get(0);
    if (dateString == null) {
        return null;
    }
    try {
        Date date = DateUtils.parseDate(dateString.toString(), new String[]{"yyyy-MM-dd HH:mm:ss"});
        return DateFormatUtils.format(date, formatPattern);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return null;
}
项目:mumu-parquet    文件:MapReduceParquetMapReducerTest.java   
@Test
public void mapreduce() {
    String inputPath = ParquetConfiguration.HDFS_URI + "//parquet/mapreduce/input";
    String outputPath = ParquetConfiguration.HDFS_URI + "//parquet/mapreduce/output" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmss");
    try {
        MapReduceParquetMapReducer.main(new String[]{inputPath, outputPath});
        DistributedFileSystem distributedFileSystem = new ParquetConfiguration().distributedFileSystem();
        FileStatus[] fileStatuses = distributedFileSystem.listStatus(new Path(outputPath));
        for (FileStatus fileStatus : fileStatuses) {
            System.out.println(fileStatus);
        }
        distributedFileSystem.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:atf-toolbox-java    文件:DateUtil.java   
public static String timeAsHexDigitsString(int numberOfPlaces) {
    String answer = StringUtils.EMPTY;
    Calendar cal = Calendar.getInstance();
    String year = DateFormatUtils.format(cal, "yy");
    String month = DateFormatUtils.format(cal, "MM");
    String day = DateFormatUtils.format(cal, "dd");
    String hour = DateFormatUtils.format(cal, "kk");
    String minute = DateFormatUtils.format(cal, "mm");
    String second = DateFormatUtils.format(cal, "ss");

    answer += Long.toHexString(Long.parseLong(year));
    answer += Long.toHexString(Long.parseLong(month));
    answer += Long.toHexString(Long.parseLong(day));
    answer += Long.toHexString(Long.parseLong(hour));
    answer += Long.toHexString(Long.parseLong(minute));
    answer += Long.toHexString(Long.parseLong(second));

    answer = StringUtils.right(answer, numberOfPlaces);
    return answer;
}
项目:OSCAR-ConCert    文件:ManageLinkedClients.java   
private static void copyDemographicTransferDataToScorePlaceholder(LoggedInInfo loggedInInfo, Facility facility,DemographicTransfer demographicTransfer, LinkedDemographicHolder integratorLinkedDemographicHolder) throws MalformedURLException {
    // copy the data to holder entry
    if (demographicTransfer.getBirthDate() != null) integratorLinkedDemographicHolder.birthDate = DateFormatUtils.ISO_DATE_FORMAT.format(demographicTransfer.getBirthDate());
    integratorLinkedDemographicHolder.firstName = StringUtils.trimToEmpty(demographicTransfer.getFirstName());
    integratorLinkedDemographicHolder.gender = "";
    if (demographicTransfer.getGender()!=null) integratorLinkedDemographicHolder.gender=demographicTransfer.getGender().name();
    integratorLinkedDemographicHolder.hin = StringUtils.trimToEmpty(demographicTransfer.getHin());
    integratorLinkedDemographicHolder.hinType = StringUtils.trimToEmpty(demographicTransfer.getHinType());
    integratorLinkedDemographicHolder.lastName = StringUtils.trimToEmpty(demographicTransfer.getLastName());

    CachedFacility tempFacility = CaisiIntegratorManager.getRemoteFacility(loggedInInfo, facility,demographicTransfer.getIntegratorFacilityId());
    integratorLinkedDemographicHolder.linkDestination = ClientLink.Type.OSCAR_CAISI.name() + '.' + tempFacility.getIntegratorFacilityId();
    integratorLinkedDemographicHolder.remoteLinkId = demographicTransfer.getCaisiDemographicId();

    if (demographicTransfer.getPhoto()!=null) integratorLinkedDemographicHolder.imageUrl="/imageRenderingServlet?source="+ImageRenderingServlet.Source.integrator_client.name()+"&integratorFacilityId=" + demographicTransfer.getIntegratorFacilityId()+"&caisiDemographicId=" + demographicTransfer.getCaisiDemographicId();
}
项目:scaffold    文件:Uploader.java   
/**
 * 解析上传域
 *
 * @param item 文件对象
 * @return {@link FileFormResult}
 * @throws IOException IO异常
 */
private FileFormResult processUploadedFile(FileItem item) throws IOException {
    String name = item.getName();
    String fileSuffix = FilenameUtils.getExtension(name);
    if (CollectionUtils.isNotEmpty(allowedSuffixList) && !allowedSuffixList.contains(fileSuffix)) {
        throw new NotAllowedUploadException(String.format("上传文件格式不正确,fileName=%s,allowedSuffixList=%s",
                name, allowedSuffixList));
    }
    FileFormResult file = new FileFormResult();
    file.setFieldName(item.getFieldName());
    file.setFileName(name);
    file.setContentType(item.getContentType());
    file.setSizeInBytes(item.getSize());

    //如果未设置上传路径,直接保存到项目根目录
    if (Strings.isNullOrEmpty(baseDir)) {
        baseDir = request.getRealPath("/");
    }
    File relativePath = new File(SEPARATOR + DateFormatUtils.format(new Date(), "yyyyMMdd") + file.getFileName());
    FileCopyUtils.copy(item.getInputStream(), new FileOutputStream(relativePath));
    file.setSaveRelativePath(relativePath.getAbsolutePath());
    return file;
}
项目:cuba    文件:LogWindow.java   
private String writeLog() {
    StringBuilder sb = new StringBuilder();
    List<LogItem> items = App.getInstance().getAppLog().getItems();
    for (LogItem item : items) {
        sb.append("<b>");
        sb.append(DateFormatUtils.format(item.getTimestamp(), DATE_FORMAT));
        sb.append(" ");
        sb.append(item.getLevel().name());
        sb.append("</b>&nbsp;");
        sb.append(StringEscapeUtils.escapeHtml(item.getMessage()));
        if (item.getStacktrace() != null) {
            sb.append(" ");

            String htmlMessage = StringEscapeUtils.escapeHtml(item.getStacktrace());
            htmlMessage = StringUtils.replace(htmlMessage, "\n", "<br/>");
            htmlMessage = StringUtils.replace(htmlMessage, " ", "&nbsp;");
            htmlMessage = StringUtils.replace(htmlMessage, "\t", "&nbsp;&nbsp;&nbsp;&nbsp;");

            sb.append(htmlMessage);
        }
        sb.append("<br/>");
    }
    return sb.toString();
}
项目:symphonyx    文件:ArchiveRepository.java   
/**
 * Gets the latest week archive (Sunday) with the specified time.
 *
 * @param time the specified time
 * @return archive, returns {@code null} if not found
 * @throws RepositoryException repository exception
 */
public JSONObject getWeekArchive(final long time) throws RepositoryException {
    final long weekEndTime = Times.getWeekEndTime(time);
    final String startDate = DateFormatUtils.format(time, "yyyyMMdd");
    final String endDate = DateFormatUtils.format(weekEndTime, "yyyyMMdd");

    final Query query = new Query().setCurrentPageNum(1).setPageCount(1).
            addSort(Archive.ARCHIVE_DATE, SortDirection.DESCENDING).
            setFilter(CompositeFilterOperator.and(
                    new PropertyFilter(Archive.ARCHIVE_DATE, FilterOperator.GREATER_THAN_OR_EQUAL, startDate),
                    new PropertyFilter(Archive.ARCHIVE_DATE, FilterOperator.LESS_THAN_OR_EQUAL, endDate)
            ));
    final JSONObject result = get(query);
    final JSONArray data = result.optJSONArray(Keys.RESULTS);

    if (data.length() < 1) {
        return null;
    }

    return data.optJSONObject(0);
}
项目:java-aci-api-ng    文件:ErrorProcessorTest.java   
@Test
public void testFullErrorResponse() throws XMLStreamException, AciErrorException, ProcessorException {
    try {
        // Execute the processor...
        processor.process(XmlTestUtils.getResourceAsXMLStreamReader("/com/autonomy/aci/client/services/processor/errorProcessorTestFullErrorResponse.xml"));
        fail("Should have thrown an AciErrorException");
    } catch (final AciErrorException exception) {
        // Check it...
        assertThat("errorId property not as expected.", exception.getErrorId(), is(equalTo("AutonomyIDOLServerWOBBLE1")));
        assertThat("rawErrorId property not as expected.", exception.getRawErrorId(), is(nullValue()));
        assertThat("errorString property not as expected.", exception.getErrorString(), is(equalTo("ERROR")));
        assertThat("errorDescription property not as expected.", exception.getErrorDescription(), is(equalTo("The requested action was not recognised")));
        assertThat("errorCode property not as expected.", exception.getErrorCode(), is(equalTo("ERRORNOTIMPLEMENTED")));
        assertThat("errorTime property not as expected.", DateFormatUtils.format(exception.getErrorTime(), "dd MMM yy HH:mm:ss"), is(equalTo("06 Feb 06 17:03:54")));
    }
}
项目:java-aci-api-ng    文件:ErrorProcessorTest.java   
@Test
public void testFullErrorResponseRawErrorId() throws XMLStreamException, AciErrorException, ProcessorException {
    try {
        // Execute the processor...
        processor.process(XmlTestUtils.getResourceAsXMLStreamReader("/com/autonomy/aci/client/services/processor/errorProcessorTestFullErrorResponseRawErrorId.xml"));
        fail("Should have thrown an AciErrorException");
    } catch (final AciErrorException exception) {
        // Check it...
        assertThat("errorId property not as expected.", exception.getErrorId(), is(equalTo("DAHGETQUERYTAGVALUES525")));
        assertThat("rawErrorId property not as expected.", exception.getRawErrorId(), is(equalTo("0x20D")));
        assertThat("errorString property not as expected.", exception.getErrorString(), is(equalTo("No valid parametric fields")));
        assertThat("errorDescription property not as expected.", exception.getErrorDescription(), is(equalTo("The fieldname parameter contained no valid parametric fields")));
        assertThat("errorCode property not as expected.", exception.getErrorCode(), is(equalTo("ERRORPARAMINVALID")));
        assertThat("errorTime property not as expected.", DateFormatUtils.format(exception.getErrorTime(), "dd MMM yy HH:mm:ss"), is(equalTo("09 Jul 08 15:48:22")));
    }
}
项目:java-aci-api-ng    文件:ErrorProcessorTest.java   
@Test
public void testPartialErrorResponse() throws XMLStreamException, AciErrorException, ProcessorException {
    try {
        // Execute the processor...
        processor.process(XmlTestUtils.getResourceAsXMLStreamReader("/com/autonomy/aci/client/services/processor/errorProcessorTestPartialErrorResponse.xml"));
        fail("Should have thrown an AciErrorException");
    } catch (final AciErrorException exception) {
        // Check it...
        assertThat("errorId property not as expected.", exception.getErrorId(), is(equalTo("AutonomyIDOLServerWOBBLE1")));
        assertThat("rawErrorId property not as expected.", exception.getRawErrorId(), is(nullValue()));
        assertThat("errorString property not as expected.", exception.getErrorString(), is(equalTo("ERROR")));
        assertThat("errorDescription property not as expected.", exception.getErrorDescription(), is(equalTo("The requested action was not recognised")));
        assertThat("errorCode property not as expected.", exception.getErrorCode(), is(equalTo("ERRORNOTIMPLEMENTED")));
        assertThat("errorTime property not as expected.", DateFormatUtils.format(exception.getErrorTime(), "dd MMM yy HH:mm:ss"), is(equalTo("06 Feb 06 17:03:54")));
    }
}
项目:java-aci-api-ng    文件:DocumentProcessorTest.java   
@Test
@SuppressWarnings("unchecked")
public void testCheckACIResponseForErrorWithErrorResponse() throws IOException, ProcessorException {
    try {
        // Setup with a error response file...
        final BasicHttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.setEntity(new InputStreamEntity(getClass().getResourceAsStream("/AciException-1.xml"), -1));

        // Set the AciResponseInputStream...
        final AciResponseInputStream stream = new AciResponseInputStreamImpl(response);

        // Process...
        processor.process(stream);
        fail("Should have raised an AciErrorException.");
    } catch (final AciErrorException aee) {
        // Check its properties...
        assertThat("errorId property not as expected.", aee.getErrorId(), is(equalTo("AutonomyIDOLServerWOBBLE1")));
        assertThat("errorString property not as expected.", aee.getErrorString(), is(equalTo("ERROR")));
        assertThat("errorDescription property not as expected.", aee.getErrorDescription(), is(equalTo("The requested action was not recognised")));
        assertThat("errorCode property not as expected.", aee.getErrorCode(), is(equalTo("ERRORNOTIMPLEMENTED")));
        assertThat("errorTime property not as expected.", DateFormatUtils.format(aee.getErrorTime(), "dd MMM yy HH:mm:ss"), is(equalTo("06 Feb 06 17:03:54")));
    }
}
项目:httpstreams    文件:AudioTag.java   
@Override
public String toString() {
    StringBuilder b = new StringBuilder();

    b.append("Tag-{type:").append(tagType);
    b.append(", timestamp:").append(DateFormatUtils.format(timestamp, "HH:mm:ss.SSS"));
    b.append(", streamId:").append(streamId);
    b.append(", datasize:").append(dataSize);
    b.append(", soundFormat:").append(soundFormat);
    b.append(", soundRate:").append(soundRate);
    b.append(", soundSize:").append(soundSize);
    b.append(", soundType:").append(soundType);
    b.append("}");

    return b.toString();
}
项目:httpstreams    文件:VideoTag.java   
@Override
public String toString() {
    StringBuilder b = new StringBuilder();

    String frameType = getFrameDescript();
    String codec = getCodecDescript();

    b.append("Tag-{type:").append(tagType);
    b.append(", timestamp:").append(DateFormatUtils.format(timestamp, "HH:mm:ss.SSS"));
    b.append(", streamId:").append(streamId);
    b.append(", datasize:").append(dataSize);
    b.append(", frameType:").append(frameType);
    b.append(", codec:").append(codec);


    b.append("}");

    return b.toString();
}
项目:httpstreams    文件:AacConfigTag.java   
@Override
public String toString() {
    StringBuilder b = new StringBuilder();

    b.append("AacHeader-{");   
    b.append("type:").append(tagType);     
    b.append(", timestamp:").append(DateFormatUtils.format(timestamp, "HH:mm:ss.SSS"));
    b.append(", streamId:").append(streamId);
    b.append(", datasize:").append(dataSize);
    b.append(", audioObjectType:").append(getAudioObjectDescript());
    b.append(", frequency:").append(getFrequency());
    b.append(", channel:").append(channel);

    b.append("}");

    return b.toString();
}
项目:httpstreams    文件:AvcVideoTag.java   
@Override
public String toString() {
    StringBuilder b = new StringBuilder();

    String frameType = getFrameDescript();
    String codec = getCodecDescript();

    b.append("Avc");
    b.append(AvcPacketType.isSequenceHeader(packetType)?"Header":"");
    b.append("-{type:").append(tagType);
    b.append(", timestamp:").append(DateFormatUtils.format(timestamp, "HH:mm:ss.SSS"));
    b.append(", streamId:").append(streamId);
    b.append(", datasize:").append(dataSize);
    b.append(", frameType:").append(frameType);
    b.append(", codec:").append(codec);
    b.append(", packet:").append(getPacketDescript());

    b.append("}");

    return b.toString();
}
项目:oscar-old    文件:ManageLinkedClients.java   
private static void copyDemographicTransferDataToScorePlaceholder(DemographicTransfer demographicTransfer, LinkedDemographicHolder integratorLinkedDemographicHolder) throws MalformedURLException {
    // copy the data to holder entry
    if (demographicTransfer.getBirthDate() != null) integratorLinkedDemographicHolder.birthDate = DateFormatUtils.ISO_DATE_FORMAT.format(demographicTransfer.getBirthDate());
    integratorLinkedDemographicHolder.firstName = StringUtils.trimToEmpty(demographicTransfer.getFirstName());
    integratorLinkedDemographicHolder.gender = "";
    if (demographicTransfer.getGender()!=null) integratorLinkedDemographicHolder.gender=demographicTransfer.getGender().name();
    integratorLinkedDemographicHolder.hin = StringUtils.trimToEmpty(demographicTransfer.getHin());
    integratorLinkedDemographicHolder.hinType = StringUtils.trimToEmpty(demographicTransfer.getHinType());
    integratorLinkedDemographicHolder.lastName = StringUtils.trimToEmpty(demographicTransfer.getLastName());

    CachedFacility tempFacility = CaisiIntegratorManager.getRemoteFacility(demographicTransfer.getIntegratorFacilityId());
    integratorLinkedDemographicHolder.linkDestination = ClientLink.Type.OSCAR_CAISI.name() + '.' + tempFacility.getIntegratorFacilityId();
    integratorLinkedDemographicHolder.remoteLinkId = demographicTransfer.getCaisiDemographicId();

    if (demographicTransfer.getPhoto()!=null) integratorLinkedDemographicHolder.imageUrl="/imageRenderingServlet?source="+ImageRenderingServlet.Source.integrator_client.name()+"&integratorFacilityId=" + demographicTransfer.getIntegratorFacilityId()+"&caisiDemographicId=" + demographicTransfer.getCaisiDemographicId();
}
项目:projectforge-webapp    文件:PollEventEntryPanel.java   
/**
 * @param id
 * @param model
 */
public PollEventEntryPanel(final String id, final PollEventDO poll)
{
  super(id);

  final DateTime start = new DateTime(poll.getStartDate());
  final DateTime end = new DateTime(poll.getEndDate());

  final String pattern = DateFormats.getFormatString(DateFormatType.DATE_TIME_MINUTES);
  add(new Label("startDate", "Start: " + DateFormatUtils.format(start.getMillis(), pattern)));
  add(new Label("endDate", "Ende: " + DateFormatUtils.format(end.getMillis(), pattern)));

  final AjaxIconButtonPanel iconButton = new AjaxIconButtonPanel("delete", IconType.REMOVE) {
    private static final long serialVersionUID = -2464985733387718199L;

    /**
     * @see org.projectforge.web.wicket.flowlayout.AjaxIconButtonPanel#onSubmit(org.apache.wicket.ajax.AjaxRequestTarget)
     */
    @Override
    protected void onSubmit(final AjaxRequestTarget target)
    {
      onDeleteClick(target);
    }
  };
  add(iconButton);
}
项目:CodeGenerate    文件:TemplateKeyUtil.java   
public static HashMap<String,Object> getTemplateKeyMap(TableEntity tableEntity){
    HashMap<String,Object> tmpMap = new HashMap<>();
    Date now = new Date();
    //tmpMap.put("class0", new ClassEntry("",""));
    tmpMap.put("YEAR", DateFormatUtils.format(now, "yyyy"));
    tmpMap.put("TIME", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
    tmpMap.put("USER", System.getProperty("user.name"));
    tmpMap.put("TableEntity", tableEntity);
    //tmpMap.put("PacakgeStr", tableEntity.getPackageStr());
    //tmpMap.put("Field",tableEntity.getColumnEntityList().toArray());
    return tmpMap;
}
项目:uid-generator    文件:DateUtils.java   
/**
 * Format date by 'yyyy-MM-dd' pattern
 *
 * @param date
 * @return
 */
public static String formatByDayPattern(Date date) {
    if (date != null) {
        return DateFormatUtils.format(date, DAY_PATTERN);
    } else {
        return null;
    }
}
项目:mumu-mapreduce    文件:MonthTrafficStatisticsMapReduce.java   
@Override
protected void map(final LongWritable key, final Text value, final Context context) throws IOException, InterruptedException {
    Map<String, Object> nginxLogMap = NginxAccessLogParser.parseLine(value.toString());
    String remoteAddr = nginxLogMap.get("remoteAddr").toString();
    Date accessTimeDate = (Date) nginxLogMap.get("accessTime");
    String accessTime = DateFormatUtils.format(accessTimeDate, "yyyyMM");
    context.write(new Text(accessTime), new Text(remoteAddr));
}
项目:mumu-mapreduce    文件:YearTrafficStatisticsMapReduce.java   
@Override
protected void map(final LongWritable key, final Text value, final Context context) throws IOException, InterruptedException {
    Map<String, Object> nginxLogMap = NginxAccessLogParser.parseLine(value.toString());
    String remoteAddr = nginxLogMap.get("remoteAddr").toString();
    Date accessTimeDate = (Date) nginxLogMap.get("accessTime");
    String year = DateFormatUtils.format(accessTimeDate, "yyyy");
    context.write(new Text(year), new Text(remoteAddr));
}
项目:mumu-mapreduce    文件:DailyTrafficStatisticsMapRed.java   
@Override
public void map(final LongWritable key, final Text lineValue, final OutputCollector<Text, Text> outputCollector, final Reporter reporter) throws IOException {
    Map<String, Object> nginxLogMap = NginxAccessLogParser.parseLine(lineValue.toString());
    String remoteAddr = nginxLogMap.get("remoteAddr").toString();
    String accessTime = DateFormatUtils.format((Date) nginxLogMap.get("accessTime"), "yyyyMMdd");
    outputCollector.collect(new Text(accessTime), new Text(remoteAddr));
}
项目:mumu-mapreduce    文件:MaxTemperatureMapReduceTest.java   
@Test
public void mapreduce() {
    MapReduceConfiguration mapReduceConfiguration = new MapReduceConfiguration();
    try {
        String inputPath = mapReduceConfiguration.url() + "/mapreduce/temperature/input";
        String outputPath = mapReduceConfiguration.url() + "/mapreduce/temperature/mapreduce/output" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmSS");
        MaxTemperatureMapReduce.main(new String[]{inputPath, outputPath});
        mapReduceConfiguration.print(outputPath);
    } catch (Exception e) {
        log.error(e);
    }
}
项目:dag-runner    文件:Job1.java   
@Override
protected String call() throws Exception {
    System.out.println("job1 start " + DateFormatUtils.ISO_TIME_NO_T_FORMAT.format(new Date()));
    TimeUnit.SECONDS.sleep(1);
    System.out.println("job1 return " + DateFormatUtils.ISO_TIME_NO_T_FORMAT.format(new Date()));
    return "hello job1";
}
项目:dag-runner    文件:Job2.java   
@Override
protected String call() throws Exception {
    System.out.println("job2 start " + DateFormatUtils.ISO_TIME_NO_T_FORMAT.format(new Date()));
    System.out.println("job2 got job1 value: " + job1Result);
    TimeUnit.SECONDS.sleep(1);
    System.out.println("job2 return " + DateFormatUtils.ISO_TIME_NO_T_FORMAT.format(new Date()));
    return "hello job2";
}
项目:hadoop    文件:TestYarnCLI.java   
@Test
public void testNodeStatusWithEmptyNodeLabels() throws Exception {
  NodeId nodeId = NodeId.newInstance("host0", 0);
  NodeCLI cli = new NodeCLI();
  when(client.getNodeReports()).thenReturn(
                  getNodeReports(3, NodeState.RUNNING));
  cli.setClient(client);
  cli.setSysOutPrintStream(sysOut);
  cli.setSysErrPrintStream(sysErr);
  int result = cli.run(new String[] { "-status", nodeId.toString() });
  assertEquals(0, result);
  verify(client).getNodeReports();
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  PrintWriter pw = new PrintWriter(baos);
  pw.println("Node Report : ");
  pw.println("\tNode-Id : host0:0");
  pw.println("\tRack : rack1");
  pw.println("\tNode-State : RUNNING");
  pw.println("\tNode-Http-Address : host1:8888");
  pw.println("\tLast-Health-Update : "
    + DateFormatUtils.format(new Date(0), "E dd/MMM/yy hh:mm:ss:SSzz"));
  pw.println("\tHealth-Report : ");
  pw.println("\tContainers : 0");
  pw.println("\tMemory-Used : 0MB");
  pw.println("\tMemory-Capacity : 0MB");
  pw.println("\tCPU-Used : 0 vcores");
  pw.println("\tCPU-Capacity : 0 vcores");
  pw.println("\tNode-Labels : ");
  pw.close();
  String nodeStatusStr = baos.toString("UTF-8");
  verify(sysOut, times(1)).println(isA(String.class));
  verify(sysOut).println(nodeStatusStr);
}
项目:alfresco-remote-api    文件:WebDAV.java   
/**
 * Formats the given date for use in the HTTP header
 * 
 * @param date Date
 * @return String
 */
public static String formatHeaderDate(Date date)
{
    // HTTP header date/time format
    // NOTE: According to RFC2616 dates should always be in English and in
    //        the GMT timezone see http://rfc.net/rfc2616.html#p20 for details
    return DateFormatUtils.format(date, HEADER_IF_DATE_FORMAT, TimeZone.getTimeZone("GMT"), Locale.ENGLISH);
}
项目:alfresco-remote-api    文件:WebDAV.java   
/**
 * Formats the given date for use in the HTTP header
 * 
 * @param ldate long
 * @return String
 */
public static String formatHeaderDate(long ldate)
{
    // HTTP header date/time format
    // NOTE: According to RFC2616 dates should always be in English and in
    //        the GMT timezone see http://rfc.net/rfc2616.html#p20 for details
    return DateFormatUtils.format(ldate, HEADER_IF_DATE_FORMAT, TimeZone.getTimeZone("GMT"), Locale.ENGLISH);
}
项目:mumu-pig    文件:PigQueryTest.java   
@Test
public void passwd() {
    StringBuilder builder = new StringBuilder();
    builder.append("password = load '/pig/passwd' using PigStorage(':');");
    builder.append("username_password = foreach password generate $0 as username;");
    pigQuery.query(builder.toString(), "username_password", "output/password" + DateFormatUtils.format(new Date(), "yyyyMMddHHmmss"));
}
项目:CodeGen    文件:Defaults.java   
public static Map<String, String> getDefaultVariables() {
    Map<String, String> context = new HashMap<>();
    Calendar calendar = Calendar.getInstance();
    context.put("YEAR", String.valueOf(calendar.get(Calendar.YEAR)));
    context.put("MONTH", String.valueOf(calendar.get(Calendar.MONTH) + 1));
    context.put("DAY", String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)));
    context.put("DATE", DateFormatUtils.format(calendar.getTime(), "yyyy-MM-dd"));
    context.put("TIME", DateFormatUtils.format(calendar.getTime(), "HH:mm:ss"));
    context.put("NOW", DateFormatUtils.format(calendar.getTime(), "yyyy-MM-dd HH:mm:ss"));
    context.put("USER", System.getProperty("user.name"));
    return context;
}
项目:tcp-gateway    文件:Protocol.java   
public static MessageBuf.JMTransfer.Builder generateConnect() {
    MessageBuf.JMTransfer.Builder builder = MessageBuf.JMTransfer.newBuilder();
    builder.setVersion("1.0");
    builder.setDeviceId("test");
    builder.setCmd(1000);
    builder.setSeq(1234);
    builder.setFormat(1);
    builder.setFlag(1);
    builder.setPlatform("pc");
    builder.setPlatformVersion("1.0");
    builder.setToken("abc");
    builder.setAppKey("123");
    builder.setTimeStamp("123456");
    builder.setSign("123");

    Login.MessageBufPro.MessageReq.Builder logReq = Login.MessageBufPro.MessageReq.newBuilder();
    logReq.setMethod("connect");
    logReq.setToken("iosaaa");
    logReq.setParam("123");
    logReq.setSign("ios333");
    logReq.setTime(DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
    logReq.setV("1.0");
    logReq.setDevice("tcp test");
    logReq.setApp("server");
    logReq.setCmd(Login.MessageBufPro.CMD.CONNECT); // 连接

    builder.setBody(logReq.build().toByteString());

    return builder;
}
项目:tcp-gateway    文件:Protocol.java   
public static MessageBuf.JMTransfer.Builder generateHeartbeat() {
    MessageBuf.JMTransfer.Builder builder = MessageBuf.JMTransfer.newBuilder();
    builder.setVersion("1.0");
    builder.setDeviceId("test");
    builder.setCmd(1002);
    builder.setSeq(1234);
    builder.setFormat(1);
    builder.setFlag(1);
    builder.setPlatform("pc");
    builder.setPlatformVersion("1.0");
    builder.setToken("abc");
    builder.setAppKey("123");
    builder.setTimeStamp("123456");
    builder.setSign("123");

    Login.MessageBufPro.MessageReq.Builder heartbeatReq = Login.MessageBufPro.MessageReq.newBuilder();
    heartbeatReq.setMethod("123");
    heartbeatReq.setToken("iosaaa");
    heartbeatReq.setParam("123");
    heartbeatReq.setSign("ios333");
    heartbeatReq.setTime(DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
    heartbeatReq.setV("1.0");
    heartbeatReq.setDevice("tcp test");
    heartbeatReq.setApp("server");
    heartbeatReq.setCmd(Login.MessageBufPro.CMD.HEARTBEAT); // 心跳

    builder.setBody(heartbeatReq.build().toByteString());

    return builder;
}
项目:sjk    文件:TestTime.java   
/**
 * @param args
 * @throws ParseException
 */
public static void main(String[] args) throws ParseException {
    // 2013-02-25 16:45:00

    Date spDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2013-02-25 16:45:00");

    String curDateString = DateFormatUtils.format(DateUtils.addDays(spDate, -1), "yyyy-MM-dd");
    logger.debug(curDateString);
}
项目:sjk    文件:AppServiceImpl.java   
@Override
public List<App> FindAll() {

    String curDateString = DateFormatUtils.format(DateUtils.addDays(new Date(), config.getGenerateDate()),
            "yyyy-MM-dd HH:mm:ss");
    Date curDate = DateUtils.addDays(new Date(), config.getGenerateDate());
    appDicts = daoDict.findAll();
    screenImageList = daoScreenImage.findAll();
    extendDataList = daoExtendData.findAll();
    org.apache.velocity.Template templateVelocity = new VeTemplate(config.getAppGenerateTemplateBaseDir(),
            "app.html").getTemplate();
    Template template = new Template(config.getAppGenerateTemplateBaseDir(), "detail.html");
    List<App> list;
    logger.debug("run time :{}", curDateString);
    if (config.getGenerateDate() == 0) {
        list = dao.findAll();
    } else {
        list = dao.findAll(curDate);
    }
    for (App app : list) {
        setApp(app);
        // genetatePage(app);
        // genetatePage(app, template);
        genetatePageVelocity(app, templateVelocity);
    }
    return list;
}