Example usage for java.util Date getDate

List of usage examples for java.util Date getDate

Introduction

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

Prototype

@Deprecated
public int getDate() 

Source Link

Document

Returns the day of the month represented by this Date object.

Usage

From source file:com.crs4.roodin.bayesian.SessionsLogger.java

/**
 * Create and save a new session for the user inside the building
 * //from  w w w .ja v  a2 s. c om
 * @param sessionid the id of this session
 * @param startpos is the initial position
 * @param shape is the entire map shape 
 * @param barred the shape of barreds, usually a JSONArray of row,col as barred
 * @param ppm pixel per meter
 * @return the sessionid
 * @throws JSONException
 */
public String saveSession(String sessionid, JSONArray startpos, JSONArray shape, JSONArray barred, int ppm)
        throws JSONException {

    Map<String, Object> session = new HashMap<String, Object>();
    Date date = new Date();

    session.put("id", sessionid);
    session.put("date_created", date.getDate()); //TODO la data  diversa da python
    session.put("probs", new double[shape.getInt(0)][shape.getInt(1)]); //numpy.zeros(shape),
    session.put("barred", convertToMatrix(barred));
    session.put("ppm", ppm);

    sessions.put(sessionid, session);

    System.out.println("session put: " + sessionid);

    return sessionid;
}

From source file:de.forsthaus.webui.calendar.model.CalendarDateFormatter.java

/**
 * This is for the month view, means mold="month" .<br>
 * EN: on every first of month the 3 digits month name is shown.<br>
 * DE: an jedem ersten des Monats wird der Monatsname (3-stellig) angezeigt.<br>
 *//*from w  w  w  . j a va 2 s.com*/
@Override
public String getCaptionByDateOfMonth(Date date, Locale locale, TimeZone timezone) {

    String s = ZksampleDateFormat.getDayNumberFormater().format(date);

    if (date.getDate() == 1) {
        return ZksampleDateFormat.getMonth3DigitsFormater().format(date) + " " + s;
    } else
        return s;
}

From source file:org.alfresco.repo.web.scripts.content.StreamJMXDump.java

/**
 * @see org.springframework.extensions.webscripts.WebScript#execute(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.WebScriptResponse)
 *///from   ww w . j  a v  a 2s .  co m
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException {
    PrintWriter tempFileOut = null;
    ZipOutputStream zout = null;
    try {
        // content type and caching
        res.setContentType("application/zip");
        Cache cache = new Cache();
        cache.setNeverCache(true);
        cache.setMustRevalidate(true);
        cache.setMaxAge(0L);
        res.setCache(cache);

        Date date = new Date();
        String attachFileName = "jmxdump_" + (date.getYear() + 1900) + '_' + (date.getMonth() + 1) + '_'
                + (date.getDate());
        String headerValue = "attachment; filename=\"" + attachFileName + ".zip\"";

        // set header based on filename - will force a Save As from the browse if it doesn't recognize it
        // this is better than the default response of the browser trying to display the contents
        res.setHeader("Content-Disposition", headerValue);

        // write JMX data to temp file
        File tempFile = TempFileProvider.createTempFile("jmxdump", ".txt");
        tempFileOut = new PrintWriter(tempFile);
        JmxDumpUtil.dumpConnection(mbeanServer, tempFileOut);
        tempFileOut.flush();
        tempFileOut.close();
        tempFileOut = null;

        // zip output
        zout = new ZipOutputStream(res.getOutputStream());
        ZipEntry zipEntry = new ZipEntry(attachFileName + ".txt");
        zout.putNextEntry(zipEntry);
        FileCopyUtils.copy(new FileInputStream(tempFile), zout);
        zout = null;
    } catch (IOException ioe) {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST,
                "Could not output JMX dump: " + ioe.getMessage(), ioe);
    } finally {
        if (tempFileOut != null)
            tempFileOut.close();
        try {
            if (zout != null)
                zout.close();
        } catch (IOException e1) {
        }
    }
}

From source file:com.gizwits.aircondition.activity.control.MainControlActivity.java

/**
 * ??2014624 17:23./* w  ww . j  ava 2  s . co  m*/
 * 
 * @param date
 *            the date
 * @return the date cn
 */
public static String getDateCN(Date date) {
    int y = date.getYear();
    int m = date.getMonth() + 1;
    int d = date.getDate();

    int h = date.getHours();
    int mt = date.getMinutes();

    return (y + 1900) + "" + m + "" + d + "  " + h + ":" + mt;

}

From source file:org.openmrs.module.laboratory.web.export.DownloadService.java

public void downloadXLS(@ModelAttribute ExportAttributeDetailsApi adts, HttpServletRequest request,
        HttpServletResponse response) throws ClassNotFoundException, ParseException {

    // 1. Create new workbook
    HSSFWorkbook workbook = new HSSFWorkbook();

    // 2. Create new worksheet
    HSSFSheet worksheet = workbook.createSheet("Patient Lab Result Report");

    // 3. Define starting indices for rows and columns
    int startRowIndex = 0;
    int startColIndex = 0;

    // 4. Build layout
    // Build title, date, and column headers
    ExportLayouter.buildReport(worksheet, startRowIndex, startColIndex);

    // 5. Fill report
    ExportFillManager.fillReport(worksheet, startRowIndex, startColIndex, getDatasource(adts, request));

    // 6. Set the response properties
    String months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
    //ghanshyam 4-oct-2012 Support #405 [Laboratory]Export workList excel sheet name should include the investigation date not current date
    String dateStr = adts.getDateStr();
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    Date date = new Date();
    date = sdf.parse(dateStr);/*from   w  ww  .ja va 2 s.  co  m*/
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);
    String day = Integer.toString(date.getDate());
    String month = months[date.getMonth()];
    String year = Integer.toString(calendar.get(Calendar.YEAR));
    String dayMonthYear = day + "-" + month + "-" + year;
    String fileName = "PatientLabResultReport" + dayMonthYear + ".xls";
    response.setHeader("Content-Disposition", "inline; filename=" + fileName);
    // Make sure to set the correct content type
    response.setContentType("application/vnd.ms-excel");

    // 7. Write to the output stream
    ExportWriter.write(response, worksheet);
}

From source file:com.springsource.greenhouse.events.sessions.EventSessionsScheduleActivity.java

private void refreshScheduleDays() {
    if (event == null) {
        return;//  w w  w . java2s.c  om
    }

    conferenceDates = new ArrayList<Date>();
    List<String> conferenceDays = new ArrayList<String>();
    Date day = (Date) event.getStartTime().clone();

    while (day.before(event.getEndTime())) {
        conferenceDates.add((Date) day.clone());
        conferenceDays.add(new SimpleDateFormat("EEEE, MMM d").format(day));
        day.setDate(day.getDate() + 1);
    }

    setListAdapter(new ArrayAdapter<String>(this, R.layout.menu_list_item, conferenceDays));
}

From source file:graficos.GraficoGantt.java

private Date getFechaIncremento(Date fecha_com, int unidad_tiempo, int incremento) {
    Calendar calendario = Calendar.getInstance();
    calendario.set(fecha_com.getYear() + 1900, fecha_com.getMonth(), fecha_com.getDate());
    if (unidad_tiempo == Calendar.DATE)
        calendario.add(Calendar.DATE, incremento);
    else if (unidad_tiempo == Calendar.MONTH)
        calendario.add(Calendar.MONTH, incremento);
    else/*from w  w w.  ja  v  a2  s.c  o  m*/
        calendario.add(Calendar.YEAR, incremento);
    Date fecha = calendario.getTime();
    return fecha;
}

From source file:com.datatorrent.contrib.enrich.FileEnrichmentTest.java

@Test
public void testEnrichmentOperatorDelimitedFSLoader() throws IOException, InterruptedException {
    URL origUrl = this.getClass().getResource("/productmapping-delim.txt");

    URL fileUrl = new URL(this.getClass().getResource("/").toString() + "productmapping-delim1.txt");
    FileUtils.deleteQuietly(new File(fileUrl.getPath()));
    FileUtils.copyFile(new File(origUrl.getPath()), new File(fileUrl.getPath()));
    MapEnricher oper = new MapEnricher();
    DelimitedFSLoader store = new DelimitedFSLoader();
    // store.setFieldDescription("productCategory:INTEGER,productId:INTEGER");
    store.setFileName(fileUrl.toString());
    store.setSchema(/*from   w  w w  . j  av a2  s.  c  o  m*/
            "{\"separator\":\",\",\"fields\": [{\"name\": \"productCategory\",\"type\": \"Integer\"},{\"name\": \"productId\",\"type\": \"Integer\"},{\"name\": \"mfgDate\",\"type\": \"Date\",\"constraints\": {\"format\": \"dd/MM/yyyy\"}}]}");
    oper.setLookupFields(Arrays.asList("productId"));
    oper.setIncludeFields(Arrays.asList("productCategory", "mfgDate"));
    oper.setStore(store);

    oper.setup(null);

    CollectorTestSink<Map<String, Object>> sink = new CollectorTestSink<>();
    @SuppressWarnings({ "unchecked", "rawtypes" })
    CollectorTestSink<Object> tmp = (CollectorTestSink) sink;
    oper.output.setSink(tmp);

    oper.activate(null);

    oper.beginWindow(0);
    Map<String, Object> tuple = Maps.newHashMap();
    tuple.put("productId", 3);
    tuple.put("channelId", 4);
    tuple.put("amount", 10.0);

    Kryo kryo = new Kryo();
    oper.input.process(kryo.copy(tuple));

    oper.endWindow();

    oper.deactivate();

    /* Number of tuple, emitted */
    Assert.assertEquals("Number of tuple emitted ", 1, sink.collectedTuples.size());
    Map<String, Object> emitted = sink.collectedTuples.iterator().next();

    /* The fields present in original event is kept as it is */
    Assert.assertEquals("Number of fields in emitted tuple", 5, emitted.size());
    Assert.assertEquals("value of productId is 3", tuple.get("productId"), emitted.get("productId"));
    Assert.assertEquals("value of channelId is 4", tuple.get("channelId"), emitted.get("channelId"));
    Assert.assertEquals("value of amount is 10.0", tuple.get("amount"), emitted.get("amount"));

    /* Check if productCategory is added to the event */
    Assert.assertEquals("productCategory is part of tuple", true, emitted.containsKey("productCategory"));
    Assert.assertEquals("value of product category is 1", 5, emitted.get("productCategory"));
    Assert.assertTrue(emitted.get("productCategory") instanceof Integer);

    /* Check if mfgDate is added to the event */
    Assert.assertEquals("mfgDate is part of tuple", true, emitted.containsKey("productCategory"));
    Date mfgDate = (Date) emitted.get("mfgDate");
    Assert.assertEquals("value of day", 1, mfgDate.getDate());
    Assert.assertEquals("value of month", 0, mfgDate.getMonth());
    Assert.assertEquals("value of year", 2016, mfgDate.getYear() + 1900);
    Assert.assertTrue(emitted.get("mfgDate") instanceof Date);
}

From source file:com.datatorrent.contrib.enrich.FileEnrichmentTest.java

@Test
public void testEnrichmentOperatorFixedWidthFSLoader() throws IOException, InterruptedException {
    URL origUrl = this.getClass().getResource("/fixed-width-sample.txt");
    MapEnricher oper = new MapEnricher();
    FixedWidthFSLoader store = new FixedWidthFSLoader();
    store.setFieldDescription(/* w w  w  .j a  va 2  s .  co  m*/
            "Year:INTEGER:4,Make:STRING:5,Model:STRING:40,Description:STRING:40,Price:DOUBLE:8,Date:DATE:10:\"dd:mm:yyyy\"");
    store.setHasHeader(true);
    store.setPadding('_');
    store.setFileName(origUrl.toString());
    oper.setLookupFields(Arrays.asList("Year"));
    oper.setIncludeFields(Arrays.asList("Year", "Make", "Model", "Price", "Date"));
    oper.setStore(store);

    oper.setup(null);

    CollectorTestSink<Map<String, Object>> sink = new CollectorTestSink<>();
    @SuppressWarnings({ "unchecked", "rawtypes" })
    CollectorTestSink<Object> tmp = (CollectorTestSink) sink;
    oper.output.setSink(tmp);

    oper.activate(null);

    oper.beginWindow(0);
    Map<String, Object> tuple = Maps.newHashMap();
    tuple.put("Year", 1997);

    Kryo kryo = new Kryo();
    oper.input.process(kryo.copy(tuple));

    oper.endWindow();

    oper.deactivate();
    oper.teardown();

    /* Number of tuple, emitted */
    Assert.assertEquals("Number of tuple emitted ", 1, sink.collectedTuples.size());
    Map<String, Object> emitted = sink.collectedTuples.iterator().next();

    /* The fields present in original event is kept as it is */
    Assert.assertEquals("Number of fields in emitted tuple", 5, emitted.size());
    Assert.assertEquals("Value of Year is 1997", tuple.get("Year"), emitted.get("Year"));

    /* Check if Make is added to the event */
    Assert.assertEquals("Make is part of tuple", true, emitted.containsKey("Make"));
    Assert.assertEquals("Value of Make", "Ford", emitted.get("Make"));

    /* Check if Model is added to the event */
    Assert.assertEquals("Model is part of tuple", true, emitted.containsKey("Model"));
    Assert.assertEquals("Value of Model", "E350", emitted.get("Model"));

    /* Check if Price is added to the event */
    Assert.assertEquals("Price is part of tuple", true, emitted.containsKey("Price"));
    Assert.assertEquals("Value of Price is 3000", 3000.0, emitted.get("Price"));
    Assert.assertTrue(emitted.get("Price") instanceof Double);

    /* Check if Date is added to the event */
    Assert.assertEquals("Date is part of tuple", true, emitted.containsKey("Date"));
    Date mfgDate = (Date) emitted.get("Date");
    Assert.assertEquals("value of day", 1, mfgDate.getDate());
    Assert.assertEquals("value of month", 0, mfgDate.getMonth());
    Assert.assertEquals("value of year", 2016, mfgDate.getYear() + 1900);
    Assert.assertTrue(emitted.get("Date") instanceof Date);

}

From source file:UserInterface.ControlManagerRole.ControlManagerWorkAreaJPanel.java

private void taxButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_taxButtonActionPerformed
    // TODO add your handling code here:
    int averageNumber = 0;
    double emissionAverageCO2 = 0;
    double normalCO2 = 0;
    double emissionAverageNOx = 0;
    double normalNOx = 0;

    for (Network network : system.getNetworkList()) {
        if (network.getName().equalsIgnoreCase(areaNameLbl.getText())) {
            for (Customer customer : network.getCustomerDirectory().getCustomerDirectory()) {
                //do for all customers
                averageNumber = 0;/*w  w  w .ja va  2s.  co m*/
                //  if (customer.getFirstName().equalsIgnoreCase("Payal")) {
                if (customer.getPrevDateCount() < customer.getRecentCount()) {
                    //   averageNumber = 0;
                    for (Sensor sensor : customer.getSensorDirectory().getSensorDirectory()) {
                        Date date = new Date();
                        averageNumber++;
                        if (sensor.getDate().getDate() == date.getDate()) {
                            emissionAverageCO2 = emissionAverageCO2 + sensor.getCurrentEmissionCO2();
                            normalCO2 = normalCO2 + sensor.getNormalCO2();

                            emissionAverageNOx = emissionAverageNOx + sensor.getCurrentEmissionNOx();
                            normalNOx = normalNOx + sensor.getNormalNOx();
                        }
                    }
                    emissionAverageCO2 = emissionAverageCO2 / averageNumber;
                    normalCO2 = normalCO2 / averageNumber;

                    emissionAverageNOx = emissionAverageNOx / averageNumber;
                    normalNOx = normalNOx / averageNumber;
                    if (emissionAverageCO2 > normalCO2 || emissionAverageNOx > normalNOx) {
                        int Tax = 0;
                        Tax = customer.getTax();
                        Tax = Tax + 100;
                        customer.setTax(Tax);
                        DateTime dtOrg = new DateTime();
                        System.out.println(dtOrg);
                        dtOrg = dtOrg.plusDays(1);
                        customer.setDueDate(dtOrg.toDate());
                    } else {
                        int Tax = 0;
                        Tax = customer.getTax();
                        Tax = Tax + 10;
                        customer.setTax(Tax);
                        DateTime dtOrg = new DateTime();
                        System.out.println(dtOrg);
                        dtOrg = dtOrg.plusDays(1);
                        customer.setDueDate(dtOrg.toDate());
                    }
                }
            }
        }
        JOptionPane.showMessageDialog(this, "Tax Incurred to Customer!!!");
    }
}