Example usage for java.util Date toString

List of usage examples for java.util Date toString

Introduction

In this page you can find the example usage for java.util Date toString.

Prototype

public String toString() 

Source Link

Document

Converts this Date object to a String of the form:
 dow mon dd hh:mm:ss zzz yyyy
where:
  • dow is the day of the week ( Sun, Mon, Tue, Wed, Thu, Fri, Sat ).

    Usage

    From source file:org.mifos.framework.util.helpers.DateUtils.java

    public static String getCurrentDate(Locale locale) throws InvalidDateException {
        // the following line is for 1.1 release and will be removed when date
        // is localized
        locale = internalLocale;//from  www  . j  a  va 2 s.  c o  m
        Calendar currentCalendar = getCurrentDateCalendar();
        java.sql.Date currentDate = new java.sql.Date(currentCalendar.getTimeInMillis());
        SimpleDateFormat format = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, locale);
        String userfmt = convertToCurrentDateFormat(format.toPattern());
        return convertDbToUserFmt(currentDate.toString(), userfmt);
    }
    

    From source file:org.mifos.framework.util.helpers.DateUtils.java

    public static String getCurrentDate() throws InvalidDateException {
        Calendar currentCalendar = getCurrentDateCalendar();
        java.sql.Date currentDate = new java.sql.Date(currentCalendar.getTimeInMillis());
        SimpleDateFormat format = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, internalLocale);
        String userfmt = convertToCurrentDateFormat(format.toPattern());
        return convertDbToUserFmt(currentDate.toString(), userfmt);
    }
    

    From source file:org.agatom.springatom.webmvc.converters.LongToDateTimeConverter.java

    /** {@inheritDoc} */
    @Override/* ww  w .j a  v  a2s  .co m*/
    public DateTime convert(final Long source) {
        final Date date = new Date(source);
        final String str = date.toString();
        return DateTime.parse(str);
    }
    

    From source file:org.cyberoam.iview.charts.Chart.java

    public static void generatePDFReport(OutputStream out, int reportID, String applianceID, String startDate,
            String endDate, String limit, int[] deviceIDs, HttpServletRequest request, int reportGroupID,
            LinkedHashMap paramMap) throws Exception {
        float width = 768;
        float height = 1024;
        float rec_hieght = 470;
        Rectangle pagesize = new Rectangle(768, 1024);
        Document document = new Document(pagesize, 30, 30, 30, 30);
        IndexManager indexManager = null;//from w ww  .  ja v  a2  s.  c  o  m
        JFreeChart chart = null;
        SqlReader sqlReader = new SqlReader(false);
        CyberoamLogger.sysLog.debug("reportID:" + reportID);
        CyberoamLogger.sysLog.debug("applianceID:" + applianceID);
        CyberoamLogger.sysLog.debug("startDate:" + startDate);
        CyberoamLogger.sysLog.debug("endDate:" + endDate);
        CyberoamLogger.sysLog.debug("limit:" + limit);
    
        try {
            //PdfWriter writer = PdfWriter.getInstance(document, response!=null ? response.getOutputStream():new FileOutputStream(pdfFileName));         
            PdfWriter writer = PdfWriter.getInstance(document, out);
            writer.setPageEvent(new Chart());
            document.addAuthor("iView");
            document.addSubject("iView Report");
            document.open();
            PdfContentByte contentByte = writer.getDirectContent();
            //ReportGroupBean reportGroupBean=ReportGroupBean.getRecordbyPrimarykey(reportGroupID);
    
            //ArrayList reportList=reportGroupBean.getReportIdByReportGroupId(reportGroupID);          
            ReportBean reportBean;
            ResultSetWrapper rsw = null;
    
            String seperator = System.getProperty("file.separator");
            //         String path=System.getProperty("catalina.home") +seperator+"webapps" +seperator+"ROOT" + seperator + "images" + seperator; 
            String path = InitServlet.contextPath + seperator + "images" + seperator + "iViewPDF.jpg";
            /*          
             *   Loading Image to add into PDF 
             */
    
            Image iViewImage = Image.getInstance(path);
            iViewImage.scaleAbsolute(750, 900);
            //iViewImage.scaleAbsolute(600,820);
            iViewImage.setAbsolutePosition(10, 10);
    
            /*Image headerImage= Image.getInstance(path+ "iViewPDFHeader.jpg");
                    
            PdfPTable headerTable = new PdfPTable(2);
            PdfPCell cell = new PdfPCell(headerImage);
            headerTable.addCell(cell);         
            HeaderFooter docHeader=null;         
            //document.setHeader(new HeaderFooter(new Phrase(new Chunk())), true);
            */
            document.add(iViewImage);
    
            document.add(new Paragraph("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"));
    
            /*
             *   Generating Table on the First Page of Report providing summary of Content 
             */
            PdfPTable frontPageTable = new PdfPTable(2);
    
            PdfPCell dataCell;
            String reportName = "";
    
            Color tableHeadBackColor = new Color(150, 174, 190);
            Color tableContentBackColor = new Color(229, 232, 237);
            Color tableBorderColor = new Color(229, 232, 237);
    
            dataCell = new PdfPCell(new Phrase(new Chunk("Report Profile",
                    FontFactory.getFont(FontFactory.HELVETICA_BOLD, 16, Font.PLAIN, new Color(255, 255, 255)))));
            dataCell.setBackgroundColor(tableHeadBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
            if (paramMap != null) {
                reportName = paramMap.get("title").toString();
                paramMap.remove("title");
            }
            if (request != null) {
                ReportGroupBean reportGroupBean = ReportGroupBean.getRecordbyPrimarykey(reportGroupID);
                reportName = getFormattedTitle(request, reportGroupBean, true);
            }
            dataCell = new PdfPCell();
    
            dataCell.addElement(new Phrase(new Chunk(reportName,
                    FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(255, 255, 255)))));
            //dataCell.addElement(new Phrase(new Chunk(ReportBean.getRecordbyPrimarykey(reportID).getTitle(), FontFactory.getFont(FontFactory.HELVETICA_BOLD, 11, Font.PLAIN, new Color(10,10,10)))));
            if (request != null) {
                dataCell.addElement(new Phrase(new Chunk(reportName + " >> ", FontFactory
                        .getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(255, 255, 255)))));
                dataCell.addElement(
                        new Phrase(new Chunk(ReportBean.getRecordbyPrimarykey(reportID).getTitle(), FontFactory
                                .getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(255, 255, 255)))));
            }
            dataCell.setBackgroundColor(tableHeadBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
    
            dataCell = new PdfPCell(new Phrase(new Chunk("Start Date",
                    FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
            dataCell.setBackgroundColor(tableContentBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
    
            dataCell = new PdfPCell(new Phrase(startDate));
            dataCell.setBackgroundColor(tableContentBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
    
            dataCell = new PdfPCell(new Phrase(new Chunk("End Date",
                    FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
            dataCell.setBackgroundColor(tableContentBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
    
            dataCell = new PdfPCell(new Phrase(endDate));
            dataCell.setBackgroundColor(tableContentBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
    
            dataCell = new PdfPCell(new Phrase(new Chunk("iView Server Time",
                    FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
            dataCell.setBackgroundColor(tableContentBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
    
            java.util.Date currentDate = new java.util.Date();
            dataCell = new PdfPCell(new Phrase(currentDate.toString()));
            dataCell.setBackgroundColor(tableContentBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
    
            dataCell = new PdfPCell(new Phrase(new Chunk("Device Names (IP Address)",
                    FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
            dataCell.setBackgroundColor(tableContentBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
    
            DeviceBean deviceBean = null;
            String deviceNameWithIP = "";
            if (deviceIDs != null) {
                for (int i = 0; i < deviceIDs.length; i++) {
                    deviceBean = DeviceBean.getRecordbyPrimarykey(deviceIDs[i]);
                    if (deviceBean != null) {
                        deviceNameWithIP += " " + (i + 1) + ". " + deviceBean.getName() + " (" + deviceBean.getIp()
                                + ")\n";
                    }
                }
            }
            dataCell = new PdfPCell(new Phrase("\n" + deviceNameWithIP + "\n"));
            dataCell.setBackgroundColor(tableContentBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
    
            /*
             * Adding Table to PDF      
             */
            document.add(frontPageTable);
    
            /*
             * Adding Charts and Table to PDF 
             */
            document.newPage();
            reportBean = ReportBean.getRecordbyPrimarykey(reportID);
            String query = null;
            if (request == null) {
                query = PrepareQuery.getQuery(reportBean, startDate, endDate, applianceID, null, null, "0", limit,
                        paramMap);
            } else {
                PrepareQuery prepareQuery = new PrepareQuery();
                query = prepareQuery.getQuery(reportBean, request);
            }
            String searchQuery = "";
            if (request == null) {
                searchQuery = null;
            } else {
                searchQuery = request.getParameter("searchquery");
            }
            if (searchQuery != null && !"".equalsIgnoreCase(searchQuery)) {
                query = query.replaceFirst("where", "where " + searchQuery + " and");
            }
            CyberoamLogger.sysLog.debug("PDF:ReportID:" + reportBean.getReportId() + "Query->" + query);
            try {
                if (query.indexOf("select") == -1 && query.indexOf("SELECT") == -1) {
                    indexManager = new IndexManager();
                    rsw = indexManager.getSearch(query);
                    //rsw=indexManager.getResutSetFromArrayList(searchRecord);
                } else {
                    rsw = sqlReader.getInstanceResultSetWrapper(query);
                }
            } catch (org.postgresql.util.PSQLException e) {
                if (query.indexOf("5min_ts_20") > -1) {
                    query = query.substring(0, query.indexOf("5min_ts_20")) + "4hr"
                            + query.substring(query.indexOf("5min_ts_20") + 16, query.length());
                    CyberoamLogger.appLog.debug("New query : " + query);
                    rsw = sqlReader.getInstanceResultSetWrapper(query);
                } else {
                    CyberoamLogger.appLog.error("Exeption in AjaxController.java " + e, e);
                }
            } catch (Exception e) {
                CyberoamLogger.appLog.error("Exeption in AjaxController.java " + e, e);
                rsw.close();
            }
            /*
             * PDF Rendering work starts here
             */
            //if(Integer.parseInt(limit)<=10 && query.indexOf("where")>-1){
            if (reportBean.getReportFormatId() != 2) {
                chart = Chart.getChart(reportBean.getReportId(), rsw, null);
                PdfTemplate pdfTemplate = contentByte.createTemplate(width, height);
                Graphics2D graphics2D = pdfTemplate.createGraphics(width, height);
                Rectangle2D rectangle = new Rectangle2D.Double(100, 85, 540, rec_hieght);
                chart.draw(graphics2D, rectangle);
                graphics2D.dispose();
                contentByte.addTemplate(pdfTemplate, 0, 0);
    
                for (int j = 0; j < (int) (rec_hieght / 16) + 1; j++) {
                    document.add(new Paragraph("\n"));
                }
            } else
                document.add(new Paragraph("\n"));
    
            // Retrieving PdfPTable
            PdfPTable pdfTable = getPdfPTable(reportBean, rsw);
            rsw.close();
    
            document.add(pdfTable);
            CyberoamLogger.appLog.info("*************Finishing PDF Work****************");
        } catch (Exception e) {
    
            CyberoamLogger.sysLog.debug("Chart.writeChartToPDF.e" + e.getMessage(), e);
        } finally {
            sqlReader.close();
        }
        document.close();
    }
    

    From source file:org.cyberoam.iview.charts.Chart.java

    /**
     * Function to write a given ChartID to pdf file
     * @param pdfFileName specifies the pdf where chart is written.Please specify full path with the filename.
     * @param reportGroup id specifies the chart to be generated
     * @param startdate specifies start date 
     * @param enddate specifies end date/*from  w  ww .  ja va  2 s. c o m*/
     * @param limit specifies number of records per record to be written in report
     */
    public static void generatePDFReportGroup(OutputStream out, int reportGroupID, String applianceID,
            String startDate, String endDate, String limit, int[] deviceIDs, HttpServletRequest request,
            LinkedHashMap paramMap) throws Exception {
        float width = 768;
        float height = 1024;
        float rec_hieght = 470;
        Rectangle pagesize = new Rectangle(768, 1024);
        Document document = new Document(pagesize, 30, 30, 30, 30);
    
        JFreeChart chart = null;
        SqlReader sqlReader = new SqlReader(false);
        //CyberoamLogger.sysLog.debug("pdf:"+pdfFileName);
        CyberoamLogger.sysLog.debug("reportGroupID:" + reportGroupID);
        CyberoamLogger.sysLog.debug("applianceID:" + applianceID);
        CyberoamLogger.sysLog.debug("startDate:" + startDate);
        CyberoamLogger.sysLog.debug("endDate:" + endDate);
        CyberoamLogger.sysLog.debug("limit:" + limit);
        try {
            //PdfWriter writer = PdfWriter.getInstance(document, response!=null ? response.getOutputStream():new FileOutputStream(pdfFileName));
            PdfWriter writer = PdfWriter.getInstance(document, out);
            writer.setPageEvent(new Chart());
            document.addAuthor("iView");
            document.addSubject("iView Report");
            document.open();
            PdfContentByte contentByte = writer.getDirectContent();
            ReportGroupBean reportGroupBean = ReportGroupBean.getRecordbyPrimarykey(reportGroupID);
            ArrayList reportList = reportGroupBean.getReportIdByReportGroupId(reportGroupID);
            ReportBean reportBean;
            ResultSetWrapper rsw = null;
    
            String seperator = System.getProperty("file.separator");
    
            //String path=System.getProperty("catalina.home") +seperator+"webapps" +seperator+"ROOT" + seperator + "images" + seperator + "iViewPDF.jpg";
            String path = InitServlet.contextPath + seperator + "images" + seperator + "iViewPDF.jpg";
    
            Image iViewImage = Image.getInstance(path);
            iViewImage.scaleAbsolute(750, 900);
            //iViewImage.scaleAbsolute(600,820);
            iViewImage.setAbsolutePosition(10, 10);
            document.add(iViewImage);
    
            document.add(new Paragraph("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"));
    
            /*
             *   Generating Table on the First Page of Report providing summary of Content 
             */
            PdfPTable frontPageTable = new PdfPTable(2);
            PdfPCell dataCell;
            ReportGroupRelationBean reportGroupRelationBean;
            String reportName = "";
    
            Color tableHeadBackColor = new Color(150, 174, 190);
            Color tableContentBackColor = new Color(229, 232, 237);
            Color tableBorderColor = new Color(229, 232, 237);
    
            dataCell = new PdfPCell(new Phrase(new Chunk("Report Profile",
                    FontFactory.getFont(FontFactory.HELVETICA_BOLD, 16, Font.PLAIN, new Color(255, 255, 255)))));
            dataCell.setBackgroundColor(tableHeadBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
    
            /**
             * Getting dynamic title.
             */
            String title = "";
            if (paramMap != null) {
                title = paramMap.get("title").toString();
    
                paramMap.remove("title");
            }
            if (request != null)
                title = getFormattedTitle(request, reportGroupBean, true);
    
            dataCell = new PdfPCell(new Phrase(new Chunk(title,
                    FontFactory.getFont(FontFactory.HELVETICA_BOLD, 16, Font.PLAIN, new Color(255, 255, 255)))));
            dataCell.setBackgroundColor(tableHeadBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
    
            dataCell = new PdfPCell(new Phrase(new Chunk("Start Date",
                    FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
            dataCell.setBackgroundColor(tableContentBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
    
            dataCell = new PdfPCell(new Phrase(startDate));
            dataCell.setBackgroundColor(tableContentBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
    
            dataCell = new PdfPCell(new Phrase(new Chunk("End Date",
                    FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
            dataCell.setBackgroundColor(tableContentBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
    
            dataCell = new PdfPCell(new Phrase(endDate));
            dataCell.setBackgroundColor(tableContentBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
    
            dataCell = new PdfPCell(new Phrase(new Chunk("iView Server Time",
                    FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
            dataCell.setBackgroundColor(tableContentBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
    
            java.util.Date currentDate = new java.util.Date();
            dataCell = new PdfPCell(new Phrase(currentDate.toString()));
            dataCell.setBackgroundColor(tableContentBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
    
            dataCell = new PdfPCell(new Phrase(new Chunk("Reports",
                    FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
            dataCell.setBackgroundColor(tableContentBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
    
            int len = reportList.size();
            for (int k = 0; k < len; k++) {
                reportGroupRelationBean = (ReportGroupRelationBean) reportList.get(k);
                reportName += " " + (k + 1) + ". "
                        + ReportBean.getRecordbyPrimarykey(reportGroupRelationBean.getReportId()).getTitle() + "\n";
            }
            dataCell = new PdfPCell(new Phrase("\n" + reportName + "\n"));
            dataCell.setBackgroundColor(tableContentBackColor);
            dataCell.setBorderColor(tableBorderColor);
    
            frontPageTable.addCell(dataCell);
    
            dataCell = new PdfPCell(new Phrase(new Chunk("Device Names (IP Address)",
                    FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
            dataCell.setBackgroundColor(tableContentBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
    
            DeviceBean deviceBean = null;
            String deviceNameWithIP = "";
            if (deviceIDs != null) {
                for (int i = 0; i < deviceIDs.length; i++) {
                    deviceBean = DeviceBean.getRecordbyPrimarykey(deviceIDs[i]);
                    if (deviceBean != null) {
                        deviceNameWithIP += " " + (i + 1) + ". " + deviceBean.getName() + " (" + deviceBean.getIp()
                                + ")\n";
                    }
                }
            }
            dataCell = new PdfPCell(new Phrase("\n" + deviceNameWithIP + "\n"));
            dataCell.setBackgroundColor(tableContentBackColor);
            dataCell.setBorderColor(tableBorderColor);
            frontPageTable.addCell(dataCell);
    
            /*
             * Adding Table to PDF      
             */
            document.add(frontPageTable);
    
            /*
             * Adding Charts and Table to PDF 
             */
            for (int i = 0; i < reportList.size(); i++) {
                document.newPage();
                reportBean = ReportBean
                        .getRecordbyPrimarykey(((ReportGroupRelationBean) reportList.get(i)).getReportId());
                String query = null;
                if (request == null) {
                    query = PrepareQuery.getQuery(reportBean, startDate, endDate, applianceID, null, null, "0",
                            limit, paramMap);
                } else {
                    PrepareQuery prepareQuery = new PrepareQuery();
                    query = prepareQuery.getQuery(reportBean, request);
                }
                CyberoamLogger.sysLog.debug("PDF:ReportID:" + reportBean.getReportId() + "Query->" + query);
    
                try {
                    rsw = sqlReader.getInstanceResultSetWrapper(query);
                } catch (org.postgresql.util.PSQLException e) {
                    if (query.indexOf("5min_ts_20") > -1) {
                        query = query.substring(0, query.indexOf("5min_ts_20")) + "4hr"
                                + query.substring(query.indexOf("5min_ts_20") + 16, query.length());
                        CyberoamLogger.appLog.debug("New query : " + query);
                        rsw = sqlReader.getInstanceResultSetWrapper(query);
    
                    } else {
                        CyberoamLogger.appLog.error("Exeption in AjaxController.java " + e, e);
                    }
                } catch (Exception e) {
                    CyberoamLogger.appLog.error("Exeption in AjaxController.java " + e, e);
                    rsw.close();
                }
    
                /*
                 * PDF Rendering work starts here
                 */
    
                for (int j = 0; j < (int) (rec_hieght / 16) + 1; j++) {
                    document.add(new Paragraph("\n"));
                }
                // This fix is to resolve the problems associated with reports which don't have graphs.
                // If there is no graph associated with the report than no need to generate 
                //a chart for it.
                GraphBean graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getReportId());
                //if(graphBean!=null)
                if (reportBean.getReportFormatId() != 2) {
                    chart = Chart.getChart(reportBean.getReportId(), rsw, null);
                    PdfTemplate pdfTemplate = contentByte.createTemplate(width, height);
                    Graphics2D graphics2D = pdfTemplate.createGraphics(width, height);
                    Rectangle2D rectangle = new Rectangle2D.Double(100, 85, 540, rec_hieght);
                    chart.draw(graphics2D, rectangle);
                    graphics2D.dispose();
                    contentByte.addTemplate(pdfTemplate, 0, 0);
                } else {
                    Paragraph p = new Paragraph(reportBean.getTitle() + "\n\n",
                            FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLD));
                    p.setAlignment("center");
                    document.add(p);
                }
    
                // Retrieving PdfPTable
                PdfPTable pdfTable = getPdfPTable(reportBean, rsw);
                rsw.close();
    
                /*
                 * Adding Table to PDF
                 */
    
                document.add(pdfTable);
            }
            CyberoamLogger.appLog.info("*************Finishing Chart****************");
        } catch (Exception e) {
            CyberoamLogger.sysLog.debug("Chart.writeChartToPDF.e" + e.getMessage(), e);
        } finally {
            sqlReader.close();
        }
    
        document.close();
    }
    

    From source file:com.auditbucket.engine.repo.redis.RedisRepo.java

    @Override
    public String ping() {
        Date when = new Date();
        template.opsForValue().setIfAbsent(-99999l, when.toString().getBytes());
        template.opsForValue().getOperations().delete(-99999l);
        return "Redis is OK";
    }
    

    From source file:org.artifactory.webapp.wicket.page.config.services.cron.CronNextDatePanel.java

    private String formatDate(Date nextRunDate) {
        return nextRunDate.toString();
    }
    

    From source file:cl.preguntame.controller.TestController.java

    @ResponseBody
    @RequestMapping(value = "/nuevo", method = RequestMethod.POST)
    public String Nuevo(HttpServletRequest req) {
        Test test = new Test();
        test.setResultados(String.valueOf(req.getParameter("resultados")));
    
        Date fecha = new Date();
    
        test.setFecha(fecha.toString());
    
        Contenido contenido = new Contenido();
        contenido.setId(Integer.parseInt(req.getParameter("contenido_id")));
    
        test.setContenido(contenido);/*  w  ww.j  a v a2  s.  co m*/
    
        TestService acceso = new TestService();
        acceso.GuardarTest(test);
    
        return String.valueOf("ok");
    
    }
    

    From source file:nz.govt.natlib.ndha.wctdpsdepositor.dpsdeposit.FakeDepositWebService.java

    private String buildXmlFragment(String pdsHandle, String materialFlowId, String fileName, String producerId,
            String depositSetId, int sipId, int depositActivityId, String now) {
        DepositResultDocument depositReply = DepositResultDocument.Factory.newInstance();
        DepositResultDocument.DepositResult result = depositReply.addNewDepositResult();
        if (materialFlowId.equalsIgnoreCase("MakeError")) {
            result.setIsError(true);/*from w  w  w .  j ava 2s . c  o  m*/
            result.setMessageCode("100");
            result.setMessageDesc("Twas a dark and stormy knight");
        } else {
            result.setIsError(false);
            result.setMessageCode("0");
            result.setMessageDesc("Success");
        }
        result.setDepositActivityId(1);
        result.setSipId(1);
        result.setUserParams("pdsHandle=" + pdsHandle + ", materialFlowId=" + materialFlowId + ", subDirectoryName="
                + fileName + ", producerId=" + producerId + ", depositSetId=" + depositSetId);
        Date current = new Date();
        result.setCreationDate(current.toString());
        return depositReply.toString();
    }
    

    From source file:MWC.GUI.JFreeChart.DatedToolTipGenerator.java

    /**
    * Generates a tool tip text item for a particular item within a series.
    *
    * @param data  the dataset.//w w  w .j  a v  a  2  s .  com
    * @param series  the series (zero-based index).
    * @param item  the item (zero-based index).
    *
    * @return the tool tip text.
    */
    public String generateToolTip(final XYDataset data, final int series, final int item) {
        String result = "|" + data.getSeriesKey(series) + " | ";
        final Number x = data.getXValue(series, item);
    
        // put into Date value
        final Date newD = new Date(x.longValue());
    
        result = result + " DTG: " + newD.toString();
    
        final Number y = data.getYValue(series, item);
        if (y != null) {
            result = result + ", value: " + this.getYFormat().format(y);
        } else {
            result = result + ", y: null";
        }
    
        return result;
    }