Java Code Examples for org.apache.commons.lang.time.DateFormatUtils

The following examples show how to use org.apache.commons.lang.time.DateFormatUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: DataLink   Source File: IndexController.java    License: Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/main")
public ModelAndView main() throws Exception{
    ModelAndView mav = new ModelAndView("main");
    List<GroupInfo> groupList = groupService.getAllGroups();
    ServerStatusMonitor monitor = ServerContainer.getInstance().getServerStatusMonitor();
    List<ManagerMetaData> all = monitor.getAllAliveManagers();
    ManagerMetaData active = monitor.getActiveManagerMetaData();
    List<String> allManagerAddress = all.stream().map(ManagerMetaData::getAddress).collect(Collectors.toList());
    String allManagers = Joiner.on(",").skipNulls().join(allManagerAddress);
    String activeManager = active == null ? null : active.getAddress();
    String startTime = null;
    JvmSnapshot jvmSnapshot = JvmUtils.buildJvmSnapshot();
    if (jvmSnapshot != null) {
        startTime = DateFormatUtils.format(jvmSnapshot.getStartTime(), "yyyy-MM-dd HH:mm:ss");
    }
    mav.addObject("groupList", groupList);
    mav.addObject("allManagers", allManagers);
    mav.addObject("activeManager", activeManager);
    mav.addObject("startTime", startTime);
    return mav;
}
 
Example 2
Source Project: code-generator   Source File: TemplateUtils.java    License: Apache License 2.0 6 votes vote down vote up
private static Map<String, Object> buildContext(Entity entity, String basePackage) {
    Map<String, Object> context = Maps.newHashMap();
    context.put("clazz", entity);
    context.put("fn", MyStringUtils.class);
    context.put("BASE_PACKAGE", basePackage);
    context.put("USER", System.getProperty("user.name"));

    Calendar calendar = Calendar.getInstance();
    context.put("YEAR", calendar.get(Calendar.YEAR));
    context.put("MONTH", calendar.get(Calendar.MONTH) + 1);
    context.put("DAY", calendar.get(Calendar.DAY_OF_MONTH));

    Date now = new Date();
    context.put("DATE", DateFormatUtils.format(now, "yyyy-MM-dd"));
    context.put("TIME", DateFormatUtils.format(now, "HH:mm:ss"));
    context.put("DATE_TIME", DateFormatUtils.format(now, "yyyy-MM-dd HH:mm:ss"));
    return context;
}
 
Example 3
Source Project: CodeMaker   Source File: BaseTemplateEngine.java    License: Apache License 2.0 6 votes vote down vote up
protected Environment createEnvironment(CodeTemplate template, List<ClassEntry> selectClasses, ClassEntry currentClass) {
    Map<String, Object> map = new HashMap<>();
    for (int i = 0; i < selectClasses.size(); i++) {
        map.put("class" + i, selectClasses.get(i));
    }

    Date now = new Date();
    map.put("class", currentClass);
    map.put("YEAR", DateFormatUtils.format(now, "yyyy"));
    map.put("TIME", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
    map.put("USER", System.getProperty("user.name"));
    map.put("utils", new Utils());
    map.put("BR", "\n");
    map.put("QT", "\"");
    String className = generateClassNameAndHandleErrors(template, map);
    map.put(getClassNameKey(), className);
    return new Environment(className, map);
}
 
Example 4
Source Project: symphonyx   Source File: ArchiveRepository.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 5
Source Project: smarthome   Source File: AstroThingHandler.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Adds the provided {@link Job} to the queue (cannot be {@code null})
 *
 * @return {@code true} if the {@code job} is added to the queue, otherwise {@code false}
 */
public void schedule(Job job, Calendar eventAt) {
    long sleepTime;
    monitor.lock();
    try {
        tidyScheduledFutures();
        sleepTime = eventAt.getTimeInMillis() - new Date().getTime();
        ScheduledFuture<?> future = scheduler.schedule(job, sleepTime, TimeUnit.MILLISECONDS);
        scheduledFutures.add(future);
    } finally {
        monitor.unlock();
    }
    if (logger.isDebugEnabled()) {
        String formattedDate = DateFormatUtils.ISO_DATETIME_FORMAT.format(eventAt);
        logger.debug("Scheduled {} in {}ms (at {})", job, sleepTime, formattedDate);
    }
}
 
Example 6
/**
 * @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);
}
 
Example 7
Source Project: SpringBootLearn   Source File: TestController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 插入记录
 * @return
 */
@PostMapping("/insertJson")
public String insertJson() {
    JSONObject jsonOject = new JSONObject();
    jsonOject.put("id", DateFormatUtils.format(new Date(),"yyyyMMddhhmmss"));
    jsonOject.put("age", 25);
    jsonOject.put("name", "j-" + new Random(100).nextInt());
    jsonOject.put("date", new Date());
    String id = ElasticsearchUtil.addData(jsonOject, indexName, esType, jsonOject.getString("id"));
    return id;
}
 
Example 8
Source Project: SpringBootLearn   Source File: TestController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 插入记录
 * @return
 */
@PostMapping("/insertModel")
public String insertModel() {
    EsModel esModel = new EsModel();
    esModel.setId(DateFormatUtils.format(new Date(),"yyyyMMddhhmmss"));
    esModel.setName("m-" + new Random(100).nextInt());
    esModel.setAge(30);
    esModel.setDate(new Date());
    JSONObject jsonObject = (JSONObject) JSONObject.toJSON(esModel);
    String id = ElasticsearchUtil.addData(jsonObject, indexName, esType, jsonObject.getString("id"));
    return id;
}
 
Example 9
Source Project: feiqu-opensource   Source File: MusicController.java    License: Apache License 2.0 5 votes vote down vote up
@ResponseBody
    @PostMapping("upload")
    public Object upload(HttpServletRequest request, HttpServletResponse response, MultipartFile file){
        BaseResult result = new BaseResult();
        try{


            FqUserCache fqUser = webUtil.currentUser(request,response);
            if(fqUser == null){
                result.setResult(ResultEnum.USER_NOT_LOGIN);
                return result;
            }
            long size = file.getSize();
            if(size >  10*1000 * 1024){
                result.setResult(ResultEnum.FILE_TOO_LARGE);
                result.setMessage("上传文件大小不要超过10M");
                return result;
            }
            String musicUrl = "";
            String fileName = file.getOriginalFilename();
            String time = DateFormatUtils.format(new Date(), "yyyyMMdd");
            String path = request.getSession().getServletContext().getRealPath("upload") + File.separator + time;
            File localFile = new File(path, fileName);
            if (!localFile.exists()) {
                localFile.mkdirs();
            }
            //MultipartFile自带的解析方法
            file.transferTo(localFile);

//            String time = DateFormatUtils.format(new Date(),"yyyy/MM/dd");
            musicUrl = FileSystemClient.getClient("aliyun").upload("music/"+fileName,localFile);
//            aliyunOssClient.putObject(CommonConstant.ALIYUN_OSS_BUCKET_NAME,"music/"+fileName,file.getInputStream());
//            String musicUrl = CommonConstant.ALIOSS_URL_PREFIX+"/music/"+fileName;
            result.setData(musicUrl);
        }catch (Exception e){
            logger.error("upload music error",e);
            result.setResult(ResultEnum.FAIL);
        }
        return result;
    }
 
Example 10
Source Project: Almost-Famous   Source File: DateUtils.java    License: MIT License 5 votes vote down vote up
/**
 * 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;
    }
}
 
Example 11
Source Project: spring-cloud   Source File: Api.java    License: Apache License 2.0 5 votes vote down vote up
@PostMapping("user")
public boolean addUser() {
    User user = User.builder()
            .createTime(DateFormatUtils.format(Calendar.getInstance().getTime()
                    , "yyyy-MM-dd HH:mm:ss"))
            .userName(String.format("user_%s", index.getAndIncrement()))
            .build();
    mapper.addUser(user);
    return true;
}
 
Example 12
Source Project: spring-cloud   Source File: Api.java    License: Apache License 2.0 5 votes vote down vote up
@PutMapping("user")
public boolean updateUser() {
    User user = User.builder()
            .createTime(DateFormatUtils.format(Calendar.getInstance().getTime()
                    , "yyyy-MM-dd HH:mm:ss"))
            .userName(String.format("updated_user_%s", index.get()))
            .id(index.get())
            .build();
    mapper.updateUser(user);
    return true;
}
 
Example 13
Source Project: prong-uid   Source File: DateUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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;
    }
}
 
Example 14
Source Project: uid-generator   Source File: DateUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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;
    }
}
 
Example 15
Source Project: tcp-gateway   Source File: Protocol.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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;
}
 
Example 16
Source Project: tcp-gateway   Source File: Protocol.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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;
}
 
Example 17
Source Project: hadoop   Source File: TestYarnCLI.java    License: Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 18
Source Project: hadoop   Source File: TestYarnCLI.java    License: Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 19
Source Project: CodeGen   Source File: Defaults.java    License: MIT License 5 votes vote down vote up
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;
}
 
Example 20
Source Project: javabase   Source File: ContentIdProcessor.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 帖子最后更新日期,只能比较当前年份的的帖子
 * 日期格式 11-20  8-25  17:33
 * @param page
 * @param i
 * @return
 */
private String praseDate(Page page, int i) {
    String date= page.getHtml().xpath("//ul[@id='thread_list']/li[@class='j_thread_list clearfix'][" + (i) + "]//span[@class='threadlist_reply_date pull_right j_reply_data']/text()").toString();
    if(!StringUtils.isEmpty(date)){
        if(date.contains("-"))
            date=date.replace("-","").trim()+"0000";
        //17:33 当天的帖子
        if(date.contains(":"))
            date= DateFormatUtils.format(new Date(),"MMdd")+date.replace(":","").trim();
    }
    return  date;
}
 
Example 21
Source Project: big-c   Source File: TestYarnCLI.java    License: Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 22
Source Project: big-c   Source File: TestYarnCLI.java    License: Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 23
Source Project: symphonyx   Source File: ArchiveRepository.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Gets an archive with the specified time.
 *
 * @param time the specified time
 * @return archive, returns {@code null} if not found
 * @throws RepositoryException repository exception
 */
public JSONObject getArchive(final long time) throws RepositoryException {
    final String archiveDate = DateFormatUtils.format(time, "yyyyMMdd");

    final Query query = new Query().setCurrentPageNum(1).setPageCount(1).
            setFilter(new PropertyFilter(Archive.ARCHIVE_DATE, FilterOperator.EQUAL, archiveDate));
    final JSONObject result = get(query);
    final JSONArray data = result.optJSONArray(Keys.RESULTS);

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

    return data.optJSONObject(0);
}
 
Example 24
Source Project: symphonyx   Source File: ActivityMgmtService.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Bets 1A0001.
 *
 * @param userId the specified user id
 * @param amount the specified amount
 * @param smallOrLarge the specified small or large
 * @return result
 */
public synchronized JSONObject bet1A0001(final String userId, final int amount, final int smallOrLarge) {
    final JSONObject ret = Results.falseResult();

    if (activityQueryService.is1A0001Today(userId)) {
        ret.put(Keys.MSG, langPropsService.get("activityParticipatedLabel"));

        return ret;
    }

    final String date = DateFormatUtils.format(new Date(), "yyyyMMdd");

    final boolean succ = null != pointtransferMgmtService.transfer(userId, Pointtransfer.ID_C_SYS,
            Pointtransfer.TRANSFER_TYPE_C_ACTIVITY_1A0001, amount, date + "-" + smallOrLarge);

    ret.put(Keys.STATUS_CODE, succ);

    final String msg = succ
            ? langPropsService.get("activityBetSuccLabel") : langPropsService.get("activityBetFailLabel");
    ret.put(Keys.MSG, msg);

    try {
        final JSONObject user = userQueryService.getUser(userId);
        final String userName = user.optString(User.USER_NAME);

        // Timeline
        final JSONObject timeline = new JSONObject();
        timeline.put(Common.TYPE, Common.ACTIVITY);
        String content = langPropsService.get("timelineActivity1A0001Label");
        content = content.replace("{user}", "<a target='_blank' rel='nofollow' href='" + Latkes.getServePath()
                + "/member/" + userName + "'>" + userName + "</a>");
        timeline.put(Common.CONTENT, content);

        timelineMgmtService.addTimeline(timeline);
    } catch (final ServiceException e) {
        LOGGER.log(Level.ERROR, "Timeline error", e);
    }

    return ret;
}
 
Example 25
Source Project: poor-man-transcoder   Source File: Session.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected void initTokenReplacer()
{
	this.tokenReplacer = new TokenReplacer();
	
	this.tokenReplacer.setTokenValue(TokenReplacer.TOKEN.HOME_DIRECTORY_TOKEN_2, Globals.getEnv(Globals.Vars.HOME_DIRECTORY));
	this.tokenReplacer.setTokenValue(TokenReplacer.TOKEN.HOME_DIRECTORY_TOKEN, Globals.getEnv(Globals.Vars.HOME_DIRECTORY));
	this.tokenReplacer.setTokenValue(TokenReplacer.TOKEN.TEMPLATE_DIRECTORY, Globals.getEnv(Globals.Vars.TEMPLATE_DIRECTORY));
	this.tokenReplacer.setTokenValue(TokenReplacer.TOKEN.CURRENT_DATE_TOKEN, DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
}
 
Example 26
@Override
public AwsAddress createAddress(AwsProcessClient awsProcessClient) {
    Random random = new Random(System.currentTimeMillis());
    String publicIp = "100.64." + random.nextInt(256) + "." + random.nextInt(256);

    AwsAddress awsAddress = new AwsAddress();
    awsAddress.setUserNo(awsProcessClient.getUserNo());
    awsAddress.setPlatformNo(awsProcessClient.getPlatform().getPlatformNo());
    awsAddress.setPublicIp(publicIp);
    awsAddress.setComment("Allocate at " + DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
    awsAddressDao.create(awsAddress);

    return awsAddress;
}
 
Example 27
/**
 * TODO: メソッドコメント
 * 
 * @param awsProcessClient
 * @return
 */
public AwsAddress createAddress(AwsProcessClient awsProcessClient) {
    // Elastic IPの確保
    AllocateAddressRequest request = new AllocateAddressRequest();
    if (BooleanUtils.isTrue(awsProcessClient.getPlatformAws().getVpc())) {
        request.withDomain(DomainType.Vpc);
    }

    String publicIp;
    try {
        AllocateAddressResult result = awsProcessClient.getEc2Client().allocateAddress(request);
        publicIp = result.getPublicIp();

    } catch (AutoException e) {
        // Elastic IPの上限オーバーの場合
        if (e.getCause() instanceof AmazonServiceException
                && "AddressLimitExceeded".equals(((AmazonServiceException) e.getCause()).getErrorCode())) {
            throw new AutoApplicationException("EPROCESS-000134");
        }

        throw e;
    }

    // イベントログ出力
    processLogger.debug(null, null, "AwsElasticIpAllocate",
            new Object[] { awsProcessClient.getPlatform().getPlatformName(), publicIp });

    // AWSアドレス情報を作成
    AwsAddress awsAddress = new AwsAddress();
    awsAddress.setUserNo(awsProcessClient.getUserNo());
    awsAddress.setPlatformNo(awsProcessClient.getPlatform().getPlatformNo());
    awsAddress.setPublicIp(publicIp);
    awsAddress.setComment("Allocate at " + DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
    awsAddressDao.create(awsAddress);

    return awsAddress;
}
 
Example 28
public String getValue() {
    // get the current date from the service
    Date date = SpringContext.getBean(DateTimeService.class).getCurrentDate();

    // remove the time component
    date = DateUtils.truncate(date, Calendar.DAY_OF_MONTH);

    // format it as expected
    return DateFormatUtils.format(date, "MM/dd/yyyy");
}
 
Example 29
/**
 * @see org.projectforge.core.AbstractBaseDO#toString()
 */
@Override
public String toString()
{
  final String pattern = DateFormats.getFormatString(DateFormatType.DATE_TIME_MINUTES);
  return DateFormatUtils.format(startDate.getTime(), pattern) + " - " + DateFormatUtils.format(endDate.getTime(), pattern);
}
 
Example 30
Source Project: tutorials   Source File: OrderService.java    License: MIT License 5 votes vote down vote up
@PostMapping("/create")
public OrderResponse createOrder(@RequestBody OrderDTO request) {

    int lastIndex = orders.size();
    Order order = new Order();
    order.setId(lastIndex + 1);
    order.setCustomerId(request.getCustomerId());
    order.setItemId(request.getItemId());
    String date = DateFormatUtils.format(new Date(), "yyyy/MM/dd");
    order.setDate(date);

    return new OrderResponse(order.getId(), order.getItemId(), "CREATED");
}