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:org.nerve.utils.StringUtils.java

/**
 * ???//w w w  . j av  a 2  s  . c o m
 *
 * @param time      
 * @return
 */
public static String processTime(Long time) {
    long oneDay = 24 * 60 * 60 * 1000;
    Date now = new Date();
    Date orginalTime = new Date(time);
    long nowDay = now.getTime() - (now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds()) * 1000;
    long yesterday = nowDay - oneDay;
    String nowHourAndMinute = toDoubleDigit(orginalTime.getHours()) + ":"
            + toDoubleDigit(orginalTime.getMinutes());
    if (time >= now.getTime()) {
        return "";
    } else if ((now.getTime() - time) < (60 * 1000)) {
        return (now.getTime() - time) / 1000 + "? " + nowHourAndMinute + " ";
    } else if ((now.getTime() - time) < (60 * 60 * 1000)) {
        return (now.getTime() - time) / 1000 / 60 + "? " + nowHourAndMinute + " ";
    } else if ((now.getTime() - time) < (24 * 60 * 60 * 1000)) {
        return (now.getTime() - time) / 1000 / 60 / 60 + "?? " + nowHourAndMinute + " ";
    } else if (time >= nowDay) {
        return " " + nowHourAndMinute;
    } else if (time >= yesterday) {
        return " " + nowHourAndMinute;
    } else {
        return toDoubleDigit(orginalTime.getMonth()) + "-" + toDoubleDigit(orginalTime.getDate()) + " "
                + nowHourAndMinute + ":" + toDoubleDigit(orginalTime.getSeconds());
    }
}

From source file:com.edgenius.wiki.blogsync.WordpressProxy.java

/**
 * Return "date_create_gmt" time is gmt, but timezone is wrong - it is local timezone. 
 * Here will correct timezone and return date in local timezone.
 * @param date/*  w  w  w .j a  v a  2 s.c o  m*/
 * @return
 */
private Date fixInputTimezone(Date date) {
    if (date == null)
        return new Date();//???

    Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    cal.set(Calendar.YEAR, date.getYear() + 1900);
    cal.set(Calendar.MONTH, date.getMonth());
    cal.set(Calendar.DATE, date.getDate());
    cal.set(Calendar.HOUR_OF_DAY, date.getHours());
    cal.set(Calendar.MINUTE, date.getMinutes());
    cal.set(Calendar.SECOND, date.getSeconds());

    Calendar local = Calendar.getInstance(TimeZone.getDefault());
    local.setTimeInMillis(cal.getTimeInMillis());
    return local.getTime();
}

From source file:br.com.nverse.sac.controllers.NewClienteCtrl.java

private void inicializarVariaveis() {

    Date data = this.cliente.getDataCadastro();
    String mes = data.getMonth() < 10 ? "0" + data.getMonth() : data.getMonth() + "";
    int ano = data.getYear() + 1900;
    String dia = data.getDate() < 10 ? "0" + data.getDate() : data.getDate() + "";
    dataCadastro = dia + "/" + mes + "/" + ano;

    agregadoAtual = new Agregado();
    veiculo = new Veiculo();
    representante = new Representante();
    contrato = new Contrato();
    historiaAtual = new Historico();
}

From source file:UserInterface.CustomerRole.CustomerTaxJPanel.java

public void displayChart(Date date1) {
    int total = 0;
    int k;//from   w w  w.j a  v a 2  s  .  c  o m
    int count = 0;
    int avg = 0;

    Sensor s = (Sensor) jTable1.getValueAt(0, 0);
    Date b = s.getDate();
    DateFormat formatter = new SimpleDateFormat("MM/dd/yy");
    Date date = new Date();
    try {
        date = formatter.parse("12/11/16");
    } catch (Exception e) {

    }
    //date = 
    System.out.println(jTable1.getValueAt(0, 5));
    System.out.println(jTable1.getValueAt(0, 4));
    list = new ArrayList<>();

    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getCurrentEmissionCO2();
            count++;
        }
    }
    avg = total / count;
    list.add(avg);

    int avg1 = 0;

    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getCurrentEmissionCO2();
            count++;
        }
    }

    avg = total / count;
    list.add(avg);
    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getNormalCO2();
            count++;
        }
    }
    avg1 = total / count;
    int avg3 = 0;
    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getCurrentEmissionNOx();
            count++;
        }
    }
    avg3 = total / count;

    int avg4 = 0;
    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getNormalNOx();
            count++;
        }
    }
    avg4 = total / count;

    int avg5 = 0;
    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getSolarCurrentEmissionCO2();
            count++;
        }
    }
    avg5 = total / count;
    int avg6 = 0;

    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getSolarNormalCO2();
            count++;
        }
    }

    avg6 = total / count;
    int avg7 = 0;
    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getSolarCurrentEmissionNOx();
            count++;
        }
    }
    avg7 = total / count;
    int avg8 = 0;
    for (int l = 0; l < jTable1.getRowCount(); l++) {
        if (date.getDate() == b.getDate()) {
            Sensor s1 = (Sensor) jTable1.getValueAt(l, 0);
            total = total + s1.getSolarNormalNOx();
            count++;
        }
    }
    avg8 = total / count;

    int combo = avg + avg3;
    int combo1 = avg5 + avg7;

    DefaultPieDataset dataset22 = new DefaultPieDataset();
    dataset22.setValue("Fuel Emission", new Integer(combo));
    dataset22.setValue("Solar Emission ", new Integer(combo1));

    JFreeChart chart22 = ChartFactory.createPieChart3D("Comparison Chart ", // chart title                   
            dataset22, // data 
            true, // include legend                   
            true, false);

    final PiePlot3D plot = (PiePlot3D) chart22.getPlot();
    plot.setStartAngle(270);
    plot.setForegroundAlpha(0.60f);
    plot.setInteriorGap(0.02);

    ChartFrame frame33 = new ChartFrame("3D Pie Chart for EMission Comparison from different sources", chart22);
    frame33.setVisible(true);
    frame33.setSize(500, 400);

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(avg, b, "curr CO2");
    dataset.setValue(avg1, b, "normal CO2");
    dataset.setValue(avg3, b, "current NOx");
    dataset.setValue(avg4, b, "normal NOx");
    //dataset.setValue(a1,b1,"current");
    JFreeChart chart = ChartFactory.createBarChart("Normal Fuel Emission Chart", "CO2 Emission", "in (g/KM)",
            dataset, PlotOrientation.VERTICAL, false, false, false);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.BLACK);
    ChartFrame frame = new ChartFrame("Bar Chart for Customer", chart);
    frame.setVisible(true);
    frame.setSize(500, 400);

    DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();
    dataset1.setValue(avg5, b, "curr CO2");
    dataset1.setValue(avg6, b, "normal CO2");
    dataset1.setValue(avg7, b, "current NOx");
    dataset1.setValue(avg8, b, "normal NOx");
    //dataset.setValue(a1,b1,"current");
    JFreeChart chart2 = ChartFactory.createBarChart("Solar Emission Chart", "CO2 Emission", "in (g/KM)",
            dataset1, PlotOrientation.VERTICAL, false, false, false);
    CategoryPlot p1 = chart.getCategoryPlot();
    p1.setRangeGridlinePaint(Color.BLACK);
    ChartFrame frame1 = new ChartFrame("Bar Chart for Customer", chart2);
    frame1.setVisible(true);
    frame1.setSize(500, 400);
}

From source file:com.vkassin.mtrade.Common.java

public static void putOrder(final Context ctx, Quote quote) {

    final Instrument it = Common.selectedInstrument;// adapter.getItem(selectedRowId);

    final Dialog dialog = new Dialog(ctx);
    dialog.setContentView(R.layout.order_dialog);
    dialog.setTitle(R.string.OrderDialogTitle);

    datetxt = (EditText) dialog.findViewById(R.id.expdateedit);
    SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
    Date dat1 = new Date();
    datetxt.setText(sdf.format(dat1));//from w ww .j  av a 2s  .c om
    mYear = dat1.getYear() + 1900;
    mMonth = dat1.getMonth();
    mDay = dat1.getDate();
    final Date dat = new GregorianCalendar(mYear, mMonth, mDay).getTime();

    datetxt.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Log.i(TAG, "Show DatePickerDialog");
            DatePickerDialog dpd = new DatePickerDialog(ctx, mDateSetListener, mYear, mMonth, mDay);
            dpd.show();
        }
    });

    TextView itext = (TextView) dialog.findViewById(R.id.instrtext);
    itext.setText(it.symbol);

    final Spinner aspinner = (Spinner) dialog.findViewById(R.id.acc_spinner);
    List<String> list = new ArrayList<String>(Common.getAccountList());
    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(Common.app_ctx,
            android.R.layout.simple_spinner_item, list);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
    aspinner.setAdapter(dataAdapter);

    final EditText pricetxt = (EditText) dialog.findViewById(R.id.priceedit);
    final EditText quanttxt = (EditText) dialog.findViewById(R.id.quantedit);

    final Button buttonpm = (Button) dialog.findViewById(R.id.buttonPriceMinus);
    buttonpm.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            try {

                double price = Double.valueOf(pricetxt.getText().toString());
                price -= 0.01;
                if (price < 0)
                    price = 0;
                pricetxt.setText(twoDForm.format(price));

            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectPrice, Toast.LENGTH_SHORT).show();
            }
        }
    });

    final Button buttonpp = (Button) dialog.findViewById(R.id.buttonPricePlus);
    buttonpp.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            try {

                double price = Double.valueOf(pricetxt.getText().toString());
                price += 0.01;
                pricetxt.setText(twoDForm.format(price));

            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectPrice, Toast.LENGTH_SHORT).show();
            }
        }
    });

    final Button buttonqm = (Button) dialog.findViewById(R.id.buttonQtyMinus);
    buttonqm.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            try {

                long qty = Long.valueOf(quanttxt.getText().toString());
                qty -= 1;
                if (qty < 0)
                    qty = 0;
                quanttxt.setText(String.valueOf(qty));

            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectQty, Toast.LENGTH_SHORT).show();
            }
        }
    });

    final Button buttonqp = (Button) dialog.findViewById(R.id.buttonQtyPlus);
    buttonqp.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            try {

                long qty = Long.valueOf(quanttxt.getText().toString());
                qty += 1;
                quanttxt.setText(String.valueOf(qty));

            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectQty, Toast.LENGTH_SHORT).show();
            }
        }
    });

    final RadioButton bu0 = (RadioButton) dialog.findViewById(R.id.radio0);
    final RadioButton bu1 = (RadioButton) dialog.findViewById(R.id.radio1);

    if (quote != null) {

        // pricetxt.setText(quote.price.toString());
        pricetxt.setText(quote.getPriceS());
        if (quote.qtyBuy > 0) {

            quanttxt.setText(quote.qtyBuy.toString());
            bu1.setChecked(true);
            bu0.setChecked(false);

        } else {

            quanttxt.setText(quote.qtySell.toString());
            bu1.setChecked(false);
            bu0.setChecked(true);

        }
    }

    Button customDialog_Cancel = (Button) dialog.findViewById(R.id.cancelbutt);
    customDialog_Cancel.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View arg0) {

            dialog.dismiss();
        }

    });

    Button customDialog_Put = (Button) dialog.findViewById(R.id.putorder);
    customDialog_Put.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View arg0) {

            Double price = new Double(0);
            Long qval = new Long(0);

            try {

                price = Double.valueOf(pricetxt.getText().toString());
            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectPrice, Toast.LENGTH_SHORT).show();
                return;
            }
            try {

                qval = Long.valueOf(quanttxt.getText().toString());
            } catch (Exception e) {

                Toast.makeText(ctx, R.string.CorrectQty, Toast.LENGTH_SHORT).show();
                return;
            }

            if (dat.compareTo(new GregorianCalendar(mYear, mMonth, mDay).getTime()) > 0) {

                Toast.makeText(ctx, R.string.CorrectDate, Toast.LENGTH_SHORT).show();

                return;

            }

            JSONObject msg = new JSONObject();
            try {

                msg.put("objType", Common.CREATE_REMOVE_ORDER);
                msg.put("time", Calendar.getInstance().getTimeInMillis());
                msg.put("version", Common.PROTOCOL_VERSION);
                msg.put("device", "Android");
                msg.put("instrumId", Long.valueOf(it.id));
                msg.put("price", price);
                msg.put("qty", qval);
                msg.put("ordType", 1);
                msg.put("side", bu0.isChecked() ? 0 : 1);
                msg.put("code", String.valueOf(aspinner.getSelectedItem()));
                msg.put("orderNum", ++ordernum);
                msg.put("action", "CREATE");
                boolean b = (((mYear - 1900) == dat.getYear()) && (mMonth == dat.getMonth())
                        && (mDay == dat.getDate()));
                if (!b)
                    msg.put("expired", String.format("%02d.%02d.%04d", mDay, mMonth + 1, mYear));

                if (isSSL) {

                    //                ? ?:    newOrder-orderNum-instrumId-side-price-qty-code-ordType
                    //               :                  newOrder-16807-20594623-0-1150-13-1027700451-1
                    String forsign = "newOrder-" + ordernum + "-" + msg.getString("instrumId") + "-"
                            + msg.getString("side") + "-"
                            + JSONObject.numberToString(Double.valueOf(msg.getDouble("price"))) + "-"
                            + msg.getString("qty") + "-" + msg.getString("code") + "-"
                            + msg.getString("ordType");
                    byte[] signed = Common.signText(Common.signProfile, forsign.getBytes(), true);
                    String gsign = Base64.encodeToString(signed, Base64.DEFAULT);
                    msg.put("gostSign", gsign);
                }
                mainActivity.writeJSONMsg(msg);

            } catch (Exception e) {

                e.printStackTrace();
                Log.e(TAG, "Error! Cannot create JSON order object", e);
            }

            dialog.dismiss();
        }

    });

    dialog.show();

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(dialog.getWindow().getAttributes());
    lp.width = WindowManager.LayoutParams.FILL_PARENT;
    lp.height = WindowManager.LayoutParams.FILL_PARENT;
    dialog.getWindow().setAttributes(lp);

}

From source file:TimeFormatter.java

/**
 * Format the given date as a string, according to the given
 * format string./*from w w  w  .  j  a v a  2 s  . c om*/
 * The format string is of the form used by the strftime(3) UNIX
 * call.
 * @param date The date to format
 * @param format The formatting string
 * @return the String with the formatted date.  */
public static String format(Date date, String format) {
    StringBuffer buf = new StringBuffer(50);
    char ch;
    for (int i = 0; i < format.length(); i++) {
        ch = format.charAt(i);
        if (ch == '%') {
            ++i;
            if (i == format.length())
                break;
            ch = format.charAt(i);
            if (ch == 'E') {
                // Alternate Era
                ++i;
            } else if (ch == 'Q') {
                // Alternate numeric symbols
                ++i;
            }
            if (i == format.length())
                break;
            ch = format.charAt(i);
            switch (ch) {
            case 'A':
                buf.append(fullWeekDays[date.getDay()]);
                break;
            case 'a':
                buf.append(abrWeekDays[date.getDay()]);
                break;

            case 'B':
                buf.append(fullMonths[date.getMonth()]);
                break;

            case 'b':
            case 'h':
                buf.append(abrMonths[date.getMonth()]);
                break;

            case 'C':
                appendPadded(buf, (date.getYear() + 1900) / 100, 2);
                break;

            case 'c':
                buf.append(date.toLocaleString());
                break;

            case 'D':
                buf.append(TimeFormatter.format(date, "%m/%d/%y"));
                break;

            case 'd':
                appendPadded(buf, date.getDate(), 2);
                break;

            case 'e':
                appendPadded(buf, date.getMonth() + 1, 2, ' ');
                break;

            case 'H':
                appendPadded(buf, date.getHours(), 2);
                break;

            case 'I':
            case 'l':
                int a = date.getHours() % 12;
                if (a == 0)
                    a = 12;
                appendPadded(buf, a, 2, ch == 'I' ? '0' : ' ');
                break;

            case 'j':
                buf.append("[?]");
                // No simple way to get this as of now
                break;

            case 'k':
                appendPadded(buf, date.getHours(), 2, ' ');
                break;

            case 'M':
                appendPadded(buf, date.getMinutes(), 2);
                break;

            case 'm':
                appendPadded(buf, date.getMonth() + 1, 2);
                break;

            case 'n':
                buf.append('\n');
                break;

            case 'p':
                buf.append(date.getHours() < 12 ? "am" : "pm");
                break;

            case 'R':
                buf.append(TimeFormatter.format(date, "%H:%M"));
                break;

            case 'r':
                buf.append(TimeFormatter.format(date, "%l:%M%p"));
                break;

            case 'S':
                appendPadded(buf, date.getSeconds(), 2);
                break;

            case 'T':
                buf.append(TimeFormatter.format(date, "%H:%M:%S"));
                break;

            case 't':
                buf.append('\t');
                break;

            case 'U':
            case 'u':
            case 'V':
            case 'W':
                buf.append("[?]");
                // Weekdays are a pain, especially
                // without day of year (0-365) ;
                break;

            case 'w':
                buf.append(date.getDay());
                break;

            case 'X':
                buf.append(TimeFormatter.format(date, "%H:%M:%S"));
                break;

            case 'x':
                buf.append(TimeFormatter.format(date, "%B %e, %Y"));
                break;

            case 'y':
                appendPadded(buf, (date.getYear() + 1900) % 100, 2);
                break;

            case 'Y':
                appendPadded(buf, (date.getYear() + 1900), 4);
                break;

            case 'Z':
                String strdate = date.toString();
                buf.append(strdate.substring(20, 23));
                // (!)
                // There should be a better way
                // to do this...
                break;
            case '%':
                buf.append('%');
                break;

            }
        } else {
            buf.append(ch);
        }
    }
    return buf.toString();
}

From source file:ca.oson.json.gson.functional.DefaultTypeAdaptersTest.java

@SuppressWarnings("deprecation")
private void assertEqualsDate(Date date, int year, int month, int day) {
    assertEquals(year - 1900, date.getYear());
    assertEquals(month, date.getMonth());
    assertEquals(day, date.getDate());
}

From source file:org.sigmah.server.endpoint.gwtrpc.handler.calendar.ActivityCalendarHandler.java

@Override
public Calendar getCalendar(Serializable identifier) {
    if (!(identifier instanceof ActivityCalendarIdentifier)) {
        throw new IllegalArgumentException(
                "Identifier must be an instance of ActivityCalendarIdentifier, received an instance of "
                        + identifier.getClass().getSimpleName());
    }//from w  w  w  .  j  a v  a2  s.  c  om

    final ActivityCalendarIdentifier activityCalendarIdentifier = (ActivityCalendarIdentifier) identifier;

    em.clear();
    final Query query = em.createQuery("SELECT l FROM LogFrame l WHERE l.parentProject.id = :projectId");
    query.setParameter("projectId", activityCalendarIdentifier.getProjectId());

    // Configuring the calendar
    final Calendar calendar = new Calendar();
    calendar.setIdentifier(identifier);
    calendar.setName(activityCalendarIdentifier.getCalendarName());
    calendar.setEditable(false);

    final HashMap<Date, List<Event>> eventMap = new HashMap<Date, List<Event>>();
    calendar.setEvents(eventMap);

    try {
        final LogFrame logFrame = (LogFrame) query.getSingleResult();

        // Preparing the activity code
        final StringBuilder codeBuilder = new StringBuilder(activityCalendarIdentifier.getActivityPrefix());
        codeBuilder.append(' ');

        // Looping on the logical framework objects
        final List<SpecificObjective> specificObjectives = logFrame.getSpecificObjectives();
        for (final SpecificObjective specificObjective : specificObjectives) {
            int baseSize = codeBuilder.length();
            codeBuilder.append((char) ('A' + specificObjective.getCode() - 1));
            codeBuilder.append('.');

            final List<ExpectedResult> expectedResults = specificObjective.getExpectedResults();
            for (final ExpectedResult expectedResult : expectedResults) {
                int specificObjectiveSize = codeBuilder.length();
                codeBuilder.append(expectedResult.getCode());
                codeBuilder.append('.');

                // For each activity
                final List<LogFrameActivity> activities = expectedResult.getActivities();
                for (final LogFrameActivity activity : activities) {
                    int expectedResultSize = codeBuilder.length();
                    codeBuilder.append(activity.getCode());
                    codeBuilder.append('.');

                    final Date startDate = activity.getStartDate();

                    if (activity.getTitle() != null) {
                        codeBuilder.append(' ');
                        codeBuilder.append(activity.getTitle());
                    }

                    // For each day
                    if (startDate != null) {
                        //if activity end date is not spcified set its value to start date
                        if (activity.getEndDate() == null) {
                            activity.setEndDate(startDate);
                        }

                        for (Date date = new Date(startDate.getYear(), startDate.getMonth(),
                                startDate.getDate()); date.compareTo(activity.getEndDate()) < 1; date
                                        .setDate(date.getDate() + 1)) {
                            final Date key = new Date(date.getTime());

                            final Event event = new Event();
                            event.setSummary(codeBuilder.toString());
                            event.setDtstart(new Date(startDate.getTime()));

                            if (startDate.equals(activity.getEndDate())) {
                                event.setDtend(new Date(startDate.getYear(), startDate.getMonth(),
                                        startDate.getDate() + 1));
                            } else {
                                event.setDtend(new Date(activity.getEndDate().getTime()));
                            }

                            event.setParent(calendar);
                            event.setIdentifier(activity.getId());

                            // Adding the event to the event map
                            List<Event> list = eventMap.get(key);
                            if (list == null) {
                                list = new ArrayList<Event>();
                                eventMap.put(key, list);
                            }
                            list.add(event);
                        }
                    }

                    codeBuilder.setLength(expectedResultSize);
                }

                codeBuilder.setLength(specificObjectiveSize);
            }

            codeBuilder.setLength(baseSize);
        }
    } catch (NoResultException e) {
        // No activities in the current project
    }

    return calendar;
}

From source file:org.opencastproject.capture.impl.SchedulerImpl.java

/**
 * Parses an date to build a cron-like time string.
 * //from   www  .ja v a 2s  . co m
 * @param date
 *          The {@code Date} you want returned in a cronstring.
 * @return A cron-like scheduling string in a {@code CronExpression} object.
 * @throws ParseException
 */
public static CronExpression getCronString(Date date) throws ParseException {
    // TODO: Remove the deprecated calls here.
    StringBuilder sb = new StringBuilder();
    sb.append(date.getSeconds() + " ");
    sb.append(date.getMinutes() + " ");
    sb.append(date.getHours() + " ");
    sb.append(date.getDate() + " ");
    sb.append(date.getMonth() + 1 + " "); // Note: Java numbers months from 0-11, Quartz uses 1-12. Sigh.
    sb.append("? ");
    sb.append(date.getYear() + 1900); // Yay java.
    return new CronExpression(sb.toString());
}

From source file:views.Student_Home.java

private void populateTasks() {
    ArrayList taskList = studentActions.fetchTasks();

    while (taskModel.getRowCount() != 0) {
        taskModel.removeRow(taskModel.getRowCount() - 1);
    }//w  w w . j  av a2s .  com

    Task task = new Task();
    Date currDate = new Date();
    int totalTime = 0;
    int timePassed = 0;
    for (int i = 0; i < taskList.size(); i++) {
        task = (Task) taskList.get(i);
        this.taskLinkedList.add(task.getTaskId());
        if (currDate.before(task.getStartDate())) {
            String[] str = { task.getTaskId(), task.getTaskDescription(), task.getProjectId(), "Up coming" };
            taskModel.insertRow(taskModel.getRowCount(), str);
        } else {
            String[] str = { task.getTaskId(), task.getTaskDescription(), task.getProjectId(), "In progress" };
            taskModel.insertRow(taskModel.getRowCount(), str);
            timePassed = timePassed + (currDate.getDate() - task.getStartDate().getDate());
        }
        totalTime = totalTime + (task.getEndDate().getDate() - task.getStartDate().getDate());

    }
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("Task completed", timePassed);
    dataset.setValue("Pending Tasks", totalTime - timePassed);
    JFreeChart taskStatusChart = ChartFactory.createPieChart("Tasks completion status", dataset, true, true,
            true);
    PiePlot piePlot = (PiePlot) taskStatusChart.getPlot();
    ChartPanel chartPanel = new ChartPanel(taskStatusChart);
    chartPanel.setSize(323, 303);
    chartPanel.setVisible(true);
    //chartPanel.setLocation(500, 200);
    taskPieChart.removeAll();
    taskPieChart.add(chartPanel);
    taskPieChart.updateUI();
    taskPieChart.repaint();
}