Example usage for java.text DateFormat getDateInstance

List of usage examples for java.text DateFormat getDateInstance

Introduction

In this page you can find the example usage for java.text DateFormat getDateInstance.

Prototype

public static final DateFormat getDateInstance(int style) 

Source Link

Document

Gets the date formatter with the given formatting style for the default java.util.Locale.Category#FORMAT FORMAT locale.

Usage

From source file:DDTDate.java

/**
 * This function will populate the varsMap with new copies of values related to display format of date & time stamps.
 * Those values are based on the class (static) date variable that is currently in use.
 * Those values can later be used in verification of UI elements that are date-originated but may change in time (say, today's date, month, year - etc.)
 * The base date that is used is Locale dependent (currently, the local is assumed to be that of the workstation running the software.)
 * When relevant, values are provided in various styles (SHORT, MEDIUM, LONG, FULL) - not all date elements have all those versions available.
 * The purpose of this 'exercise' is to set up the facility for the user to verify any component of date / time stamps independently of one another or 'traditional' formatting.
 *
 * The variables maintained here are formatted with a prefix to distinguish them from other, user defined variables.
 *
 * @TODO: enable Locale modifications (at present the test machine's locale is considered and within a test session only one locale can be tested)
 * @param varsMap//  w  w  w  .j  a v  a  2s  . c  om
 */
private void maintainDateProperties(Hashtable<String, Object> varsMap) throws Exception {

    String prefix = "$";

    try {
        // Build formatting objects for each of the output styles
        DateFormat shortStyleFormatter = DateFormat.getDateInstance(DateFormat.SHORT);
        DateFormat mediumStyleFormatter = DateFormat.getDateInstance(DateFormat.MEDIUM);
        DateFormat longStyleFormatter = DateFormat.getDateInstance(DateFormat.LONG);
        DateFormat fullStyleFormatter = DateFormat.getDateInstance(DateFormat.FULL);

        // Use a dedicated variable to hold values of formatting results to facilitate debugging
        // @TODO (maybe) when done debugging - convert to inline calls to maintainDateProperty ...
        String formatValue;

        // Examples reflect time around midnight of February 6 2014 - actual values DO NOT include quotes (added here for readability)

        MutableDateTime theReferenceDate = getReferenceDate(); //getReferenceDateAdjustedForTimeZone();
        // Default Date using DDTSettings pattern.
        formatValue = new SimpleDateFormat(defaultDateFormat()).format(theReferenceDate.toDate());
        maintainDateProperty(prefix + "defaultDate", formatValue, varsMap);

        // Short Date - '2/6/14'
        formatValue = shortStyleFormatter.format(theReferenceDate.toDate());
        maintainDateProperty(prefix + "shortDate", formatValue, varsMap);

        // Medium Date - 'Feb 6, 2014'
        formatValue = mediumStyleFormatter.format(theReferenceDate.toDate());
        maintainDateProperty(prefix + "mediumDate", formatValue, varsMap);

        // Long Date - 'February 6, 2014'
        formatValue = longStyleFormatter.format(theReferenceDate.toDate());
        maintainDateProperty(prefix + "longDate", formatValue, varsMap);

        // Full Date 'Thursday, February 6, 2014'
        formatValue = fullStyleFormatter.format(theReferenceDate.toDate());
        maintainDateProperty(prefix + "fullDate", formatValue, varsMap);

        // hours : minutes : seconds : milliseconds (broken to separate components)  -
        formatValue = theReferenceDate.toString("hh:mm:ss:SSS");
        if (formatValue.toString().contains(":")) {
            String[] hms = split(formatValue.toString(), ":");
            if (hms.length > 3) {
                // Hours - '12'
                formatValue = hms[0];
                maintainDateProperty(prefix + "hours", formatValue, varsMap);
                // Minutes - '02'
                formatValue = hms[1];
                maintainDateProperty(prefix + "minutes", formatValue, varsMap);
                // Seconds - '08'
                formatValue = hms[2];
                maintainDateProperty(prefix + "seconds", formatValue, varsMap);
                // Milliseconds - '324'
                formatValue = hms[3];
                maintainDateProperty(prefix + "milliseconds", formatValue, varsMap);
                // Hours in 24 hours format - '23'
                formatValue = theReferenceDate.toString("HH");
                maintainDateProperty(prefix + "hours24", formatValue, varsMap);
            } else
                setException("Failed to format reference date to four time units!");
        } else {
            setException("Failed to format reference date to its time units!");
        }

        // hours : minutes : seconds (default timestamp)  - '12:34:56'
        formatValue = theReferenceDate.toString("hh:mm:ss");
        maintainDateProperty(prefix + "timeStamp", formatValue, varsMap);

        // Short Year - '14'
        formatValue = theReferenceDate.toString("yy");
        maintainDateProperty(prefix + "shortYear", formatValue, varsMap);

        // Long Year - '2014'
        formatValue = theReferenceDate.toString("yyyy");
        maintainDateProperty(prefix + "longYear", formatValue, varsMap);

        // Short Month - '2'
        formatValue = theReferenceDate.toString("M");
        maintainDateProperty(prefix + "shortMonth", formatValue, varsMap);

        // Padded Month - '02'
        formatValue = theReferenceDate.toString("MM");
        maintainDateProperty(prefix + "paddedMonth", formatValue, varsMap);

        // Short Month Name - 'Feb'
        formatValue = theReferenceDate.toString("MMM");
        maintainDateProperty(prefix + "shortMonthName", formatValue, varsMap);

        // Long Month Name - 'February'
        formatValue = theReferenceDate.toString("MMMM");
        maintainDateProperty(prefix + "longMonthName", formatValue, varsMap);

        // Week in Year - '2014' (the year in which this week falls)
        formatValue = String.valueOf(theReferenceDate.getWeekyear());
        maintainDateProperty(prefix + "weekYear", formatValue, varsMap);

        // Short Day in date stamp - '6'
        formatValue = theReferenceDate.toString("d");
        maintainDateProperty(prefix + "shortDay", formatValue, varsMap);

        // Padded Day in date stamp - possibly with leading 0 - '06'
        formatValue = theReferenceDate.toString("dd");
        maintainDateProperty(prefix + "paddedDay", formatValue, varsMap);

        // Day of Year - '37'
        formatValue = theReferenceDate.toString("D");
        maintainDateProperty(prefix + "yearDay", formatValue, varsMap);

        // Short Day Name - 'Thu'
        formatValue = theReferenceDate.toString("E");
        maintainDateProperty(prefix + "shortDayName", formatValue, varsMap);

        // Long Day Name - 'Thursday'
        DateTime dt = new DateTime(theReferenceDate.toDate());
        DateTime.Property dowDTP = dt.dayOfWeek();
        formatValue = dowDTP.getAsText();
        maintainDateProperty(prefix + "longDayName", formatValue, varsMap);

        // AM/PM - 'AM'
        formatValue = theReferenceDate.toString("a");
        maintainDateProperty(prefix + "ampm", formatValue, varsMap);

        // Era - (BC/AD)
        formatValue = theReferenceDate.toString("G");
        maintainDateProperty(prefix + "era", formatValue, varsMap);

        // Time Zone - 'EST'
        formatValue = theReferenceDate.toString("zzz");
        maintainDateProperty(prefix + "zone", formatValue, varsMap);

        addComment(
                "Date variables replenished for date: " + fullStyleFormatter.format(theReferenceDate.toDate()));
        addComment(theReferenceDate.toString());
        System.out.println(getComments());
    } catch (Exception e) {
        setException(e);
    }
}

From source file:org.openregistry.core.service.DefaultPersonServiceIntegrationTests.java

/**
 * Test 3: Test of adding two new Sor Persons where there is an exact match (same SoR)
 *
 * This is an update.  TODO complete this test
 *//*from   w  w w.  j a  v  a2 s . c  om*/
@Test(expected = SorPersonAlreadyExistsException.class)
@Rollback
public void testAddExactPersonWithSameSoR() throws ReconciliationException, SorPersonAlreadyExistsException {
    final ReconciliationCriteria reconciliationCriteria = constructReconciliationCriteria(RUDYARD, KIPLING,
            null, EMAIL_ADDRESS, PHONE_NUMBER, new Date(0), OR_WEBAPP_IDENTIFIER, null);
    final ServiceExecutionResult<Person> result = this.personService.addPerson(reconciliationCriteria);
    final Person person = result.getTargetObject();

    assertTrue(result.succeeded());
    assertNotNull(result.getTargetObject().getId());
    assertEquals(1, countRowsInTable("prc_persons"));
    assertEquals(1, countRowsInTable("prc_names"));
    assertEquals(1, countRowsInTable("prs_names"));
    assertEquals(1, countRowsInTable("prs_sor_persons"));

    final SorPerson sorPerson = this.personService.findByPersonIdAndSorIdentifier(person.getId(),
            reconciliationCriteria.getSorPerson().getSourceSor());

    // check birthdate is set correctly
    Date birthDate = this.simpleJdbcTemplate
            .queryForObject("select date_of_birth from prc_persons where id = ?", Date.class, person.getId());
    DateFormat formatter = DateFormat.getDateInstance(DateFormat.SHORT);
    assertEquals(formatter.format(birthDate), formatter.format(person.getDateOfBirth()));

    // check SOR source is set correctly
    String sourceSor = this.simpleJdbcTemplate.queryForObject(
            "select source_sor_id from prs_sor_persons where person_id = ?", String.class, person.getId());
    assertEquals(sourceSor, sorPerson.getSourceSor());

    // check names in prc_names
    String familyName = this.simpleJdbcTemplate.queryForObject(
            "select family_name from prc_names where person_id = ?", String.class, person.getId());
    assertEquals(familyName, KIPLING);

    String givenName = this.simpleJdbcTemplate.queryForObject(
            "select given_name from prc_names where person_id = ?", String.class, person.getId());
    assertEquals(givenName, RUDYARD);

    // check names in prs_names
    String prsFamilyName = this.simpleJdbcTemplate.queryForObject(
            "select family_name from prs_names where sor_person_id = ?", String.class, sorPerson.getId());
    assertEquals(prsFamilyName, KIPLING);

    String prsGivenName = this.simpleJdbcTemplate.queryForObject(
            "select given_name from prs_names where sor_person_id = ?", String.class, sorPerson.getId());
    assertEquals(prsGivenName, RUDYARD);

    this.personService.addPerson(reconciliationCriteria);
}

From source file:com.nma.util.sdcardtrac.GraphFragment.java

private void drawGraph(LinearLayout view, boolean redraw) {
    float textSize, dispScale, pointSize;

    // Determine text size
    dispScale = getActivity().getResources().getDisplayMetrics().density;
    textSize = (GRAPHVIEW_TEXT_SIZE_DIP * dispScale) + 0.5f;
    pointSize = (GRAPHVIEW_POINT_SIZE_DIP * dispScale) + 0.5f;

    storageGraph = new LineGraphView(getActivity(), graphLabel);
    storageGraph.setCustomLabelFormatter(new CustomLabelFormatter() {
        String prevDate = "";

        @Override/*from   w  ww.  j  ava 2 s . com*/
        public String formatLabel(double value, boolean isValueX, int index, int lastIndex) {
            String retValue;
            boolean valueXinRange;

            valueXinRange = (index == 0) || (index == lastIndex);
            if (isValueX) { // Format time in human readable form
                if (valueXinRange) {
                    String dateStr;
                    Date currDate = new Date((long) value);

                    dateStr = DateFormat.getDateInstance(DateFormat.MEDIUM).format(currDate);

                    if (dateStr.equals(prevDate)) {
                        // Show hh:mm
                        retValue = DateFormat.getTimeInstance(DateFormat.SHORT).format(currDate);
                    } else {
                        retValue = dateStr;
                    }

                    prevDate = dateStr;
                    //Log.d(getClass().getName(), "Label is : " + retValue);
                } else {
                    retValue = " ";
                }
            } else { // Format size in human readable form
                retValue = DatabaseLoader.convertToStorageUnits(value);
                //prevDate = "";
            }
            //return super.formatLabel(value, isValueX); // let the y-value be normal-formatted
            return retValue;
        }
    });

    storageGraph.addSeries(graphSeries);
    storageGraph.setManualYAxis(true);
    storageGraph.setManualYAxisBounds(maxStorage, 0);
    storageGraph.setScalable(false);
    //storageGraph.setScrollable(true);
    storageGraph.getGraphViewStyle().setGridColor(Color.GREEN);
    storageGraph.getGraphViewStyle().setHorizontalLabelsColor(Color.YELLOW);
    storageGraph.getGraphViewStyle().setVerticalLabelsColor(Color.RED);
    storageGraph.getGraphViewStyle().setTextSize(textSize);
    storageGraph.getGraphViewStyle().setNumHorizontalLabels(2);
    storageGraph.getGraphViewStyle().setNumVerticalLabels(5);
    storageGraph.getGraphViewStyle().setVerticalLabelsWidth((int) (textSize * 4));
    //storageGraph.setMultiLineXLabel(true, ";");
    ((LineGraphView) storageGraph).setDrawBackground(true);
    ((LineGraphView) storageGraph).setDrawDataPoints(true);
    ((LineGraphView) storageGraph).setDataPointsRadius(pointSize);
    //storageGraph.highlightSample(0, true, locData.size() - 1);
    // Add selector callback
    storageGraph.setSelectHandler(this);

    setViewport(redraw);
    if (view != null) {
        view.addView(storageGraph);
    }
    if (SettingsActivity.ENABLE_DEBUG)
        Log.d(getClass().getName(), "Drew the graph, redraw=" + redraw);
}

From source file:com.sample.solutionprofile.portlet.JSPPortlet.java

public void processAction(ActionRequest req, ActionResponse res) throws IOException, PortletException {

    String command = req.getParameter("command");
    long userId = 0;
    userId = PortalUtil.getUserId(req);//from   w  w w.  ja  va2 s .c  o m
    List companyIds = null;

    int companyId = 0;
    String company_name = req.getParameter("company_names");

    if ((company_name != null) && (!company_name.isEmpty())) {
        try {
            companyId = CompanyItemDAO.getCompanyIdByName(company_name);
            System.out.println("Company for solution is" + String.valueOf(companyId));
        } catch (Exception e) {
            System.out.println("Couldn't find the company");
        }
    }
    // remove it for the moment, the user has choosed company ID
    /*try {
       companyIds = SolutionItemDAO.getCompanyIdsByUserId(userId) ;
       companyId = (Integer)companyIds.get(0); 
    } catch (Exception e) {
       System.out.println("SolutionItemDAO.getCompanyIdsByUserId throws exception for userId = " + String.valueOf(userId));
    }*/
    int id = 0;
    try {
        id = Integer.parseInt(req.getParameter("id"));
    } catch (Exception e) {
        System.out.println("Bzz");
    }

    //int companyId = 0;
    String partNumberStr = req.getParameter("partNumber");
    long partNumber = 0;
    /*try {
       partNumber  = Integer.parseInt(partNumberStr);
    }catch (Exception e) {
       System.out.println("Bzz2");
    }*/

    String solName = req.getParameter("solName");
    String solDesc = req.getParameter("solDesc");
    String partComSite = req.getParameter("partComSite");
    //int solFocus  = Integer.parseInt(req.getParameter("solFocus"));
    //int solStatusPartner = Integer.parseInt(req.getParameter("solStatusPartner"));;
    //int solStatusSAP = Integer.parseInt(req.getParameter("solStatusSAP"));

    String sapCertSince = req.getParameter("sapCertSince");
    String lastReviewBySAP = req.getParameter("lastReviewBySAP");
    int averTrainEndUser = 0;
    if (req.getParameter("averTrainEndUser") != null && !req.getParameter("averTrainEndUser").isEmpty())
        averTrainEndUser = Integer.parseInt(req.getParameter("averTrainEndUser"));
    int averImplTrainingDays = 0;
    if (req.getParameter("averImplTrainingDays") != null && !req.getParameter("averImplTrainingDays").isEmpty())
        averImplTrainingDays = Integer.parseInt(req.getParameter("averImplTrainingDays"));

    int averImplEffort = 0;
    if (req.getParameter("averImplEffort") != null && !req.getParameter("averImplEffort").isEmpty())
        averImplEffort = Integer.parseInt(req.getParameter("averImplEffort"));
    int averImplDuration = 0;
    if (req.getParameter("averImplDuration") != null && !req.getParameter("averImplDuration").isEmpty())
        averImplDuration = Integer.parseInt(req.getParameter("averImplDuration"));

    int averSizeImplTeam = 0;
    if (req.getParameter("averSizeImplTeam") != null && !req.getParameter("averSizeImplTeam").isEmpty())
        averSizeImplTeam = Integer.parseInt(req.getParameter("averSizeImplTeam"));

    int averSaleCycle = 0;
    if (req.getParameter("averSaleCycle") != null && !req.getParameter("averSaleCycle").isEmpty())
        averSaleCycle = Integer.parseInt(req.getParameter("averSaleCycle"));

    int noCustomers = 0;
    if (req.getParameter("noCustomers") != null && !req.getParameter("noCustomers").isEmpty())
        noCustomers = Integer.parseInt(req.getParameter("noCustomers"));

    int smallImpl = 0;
    if (req.getParameter("smallImpl") != null && !req.getParameter("smallImpl").isEmpty())
        smallImpl = Integer.parseInt(req.getParameter("smallImpl"));

    int largeImpl = 0;
    if (req.getParameter("largeImpl") != null && !req.getParameter("largeImpl").isEmpty())
        largeImpl = Integer.parseInt(req.getParameter("largeImpl"));

    int smallImplTime = 0;
    if (req.getParameter("smallImplTime") != null && !req.getParameter("smallImplTime").isEmpty())
        smallImplTime = Integer.parseInt(req.getParameter("smallImplTime"));

    int largeImplTime = 0;
    if (req.getParameter("largeImplTime") != null && !req.getParameter("largeImplTime").isEmpty())
        largeImplTime = Integer.parseInt(req.getParameter("largeImplTime"));

    int smallImplTeamNo = 0;
    if (req.getParameter("smallImplTeamNo") != null && !req.getParameter("smallImplTeamNo").isEmpty())
        smallImplTeamNo = Integer.parseInt(req.getParameter("smallImplTeamNo"));
    int largeImplTeamNo = 0;
    if (req.getParameter("largeImplTeamNo") != null && !req.getParameter("largeImplTeamNo").isEmpty())
        largeImplTeamNo = Integer.parseInt(req.getParameter("largeImplTeamNo"));

    String solSite = req.getParameter("solSite");

    //int countryPriceEuro = Integer.parseInt(req.getParameter("countryPriceEuro"));

    String refCustAvailForUse = req.getParameter("refCustAvailForUse");
    if (refCustAvailForUse == null) //?WHY
        refCustAvailForUse = "No";

    int totalAppBaseLinePrice = 0;
    if (req.getParameter("totalAppBaseLinePrice") != null
            && !req.getParameter("totalAppBaseLinePrice").isEmpty())
        totalAppBaseLinePrice = Integer.parseInt(req.getParameter("totalAppBaseLinePrice"));

    int appPriceEur = 0;//Integer.parseInt(req.getParameter("appPriceEur"));
    int hardwareCost = 0;
    if (req.getParameter("hardwareCost") != null && !req.getParameter("hardwareCost").isEmpty())
        hardwareCost = Integer.parseInt(req.getParameter("hardwareCost"));

    int hardwareCostEur = 0;//Integer.parseInt(req.getParameter("hardwareCostEur"));
    int averLicensePrice = 0;
    if (req.getParameter("averLicensePrice") != null && !req.getParameter("averLicensePrice").isEmpty())
        averLicensePrice = Integer.parseInt(req.getParameter("averLicensePrice"));

    int averLicensePriceEur = 0;//Integer.parseInt(req.getParameter("averLicensePriceEur"));
    int addServiceCost = 0;
    if (req.getParameter("addServiceCost") != null && !req.getParameter("addServiceCost").isEmpty())
        addServiceCost = Integer.parseInt(req.getParameter("addServiceCost"));

    int addServicePriceEur = 0;//Integer.parseInt(req.getParameter("addServicePriceEur"));
    int implCost = 0;
    if (req.getParameter("implCost") != null && !req.getParameter("implCost").isEmpty())
        implCost = Integer.parseInt(req.getParameter("implCost"));

    int implCostEur = 0;//Integer.parseInt(req.getParameter("implCostEur"));   

    String sapDiscount = req.getParameter("sapDiscount");
    String dbUsed = req.getParameter("dbUsed");
    String SAPBusUsed = req.getParameter("SAPBusUsed");
    String SAPGUIUsed = req.getParameter("SAPGUIUsed");
    String compA1B1Used = req.getParameter("compA1B1Used");
    String thirdPartyUsed = req.getParameter("thirdPartyUsed");
    String thirdPartyName = req.getParameter("thirdPartyName");
    String otherIT = req.getParameter("otherIT");
    String addRemarks = req.getParameter("addRemarks");
    String solSAPMicroSite = req.getParameter("solSAPMicroSite");

    String lastPartRevieDate = req.getParameter("solSAPMicroSite");
    String reviewedBy = req.getParameter("reviewedBy");
    if (reviewedBy == null) // WHY?
        reviewedBy = "";
    String profileAdded = req.getParameter("profileAdded");
    if (profileAdded == null) // WHY?
        profileAdded = "";
    String dateCreated = req.getParameter("dateCreated");
    String modifiedBy = req.getParameter("modifiedBy");
    if (modifiedBy == null) // WHY?
        modifiedBy = "";
    String dateUpdated = req.getParameter("dateUpdated");
    String notificationProc = req.getParameter("notificationProc");
    if (notificationProc == null) // WHY?
        notificationProc = "";
    String notificationText = req.getParameter("notificationText");
    if (notificationText == null) // WHY?
        notificationText = "";

    // childs
    String sol_countryPriceEuro = req.getParameter("country");
    String sol_solFocusStr = req.getParameter("solFocus");
    String[] sol_geographic_coverage = req.getParameterValues("geographic_coverage");
    String[] sol_industry = req.getParameterValues("industry");
    String[] sol_mySAPAllInOneVers = req.getParameterValues("mySAPAllInOneVers");
    String[] sol_mySAPOneProductVers = req.getParameterValues("mySAPOneProductVers");

    String sol_maturity = req.getParameter("maturity");
    String sol_statusByProvider = req.getParameter("statusByProvider");
    String sol_statusBySAP = req.getParameter("statusBySAP");

    String[] sol_targetCompSize = req.getParameterValues("targetCompSize");
    String[] sol_categTarget = req.getParameterValues("categTarget");
    String[] sol_langAvailable = req.getParameterValues("langAvailable");

    String sol_userType = req.getParameter("userType");

    String[] sol_progLang = req.getParameterValues("progLang");
    String[] sol_os = req.getParameterValues("os");
    String[] sol_aioBased = req.getParameterValues("aioBased");

    //search related
    try {
        SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy");
        DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
        Date tempDate = new Date();
        if (command.equals("add")) {
            // user
            // user adress + phone

            // solution
            SolutionItem solutionItem = new SolutionItem();

            //public int companyId;
            solutionItem.companyId = companyId; // get the first 
            solutionItem.solName = solName;
            solutionItem.solDesc = solDesc;
            solutionItem.partComSite = partComSite;
            //solutionItem.solFocus =    ;
            //solutionItem.solStatusPartner;
            //solutionItem.solStatusSAP;
            //solutionItem.solMaturity;
            //solutionItem.statusByProvider;
            //solutionItem.statusBySAP;
            //solutionItem.solUserType;

            //date
            if (sapCertSince != null && !sapCertSince.isEmpty()) {
                try {
                    tempDate = format.parse(sapCertSince);
                    String value = tempDate.toString();
                    System.out.println("date since = " + value);
                    solutionItem.sapCertSince = tempDate;
                } catch (ParseException ex) {
                }
            }

            if (lastReviewBySAP != null && !lastReviewBySAP.isEmpty()) {
                try {
                    tempDate = format.parse(lastReviewBySAP);
                    String value = tempDate.toString();
                    solutionItem.lastReviewBySAP = tempDate;
                } catch (ParseException ex) {
                }
            }

            solutionItem.averTrainEndUser = averTrainEndUser;
            solutionItem.averImplTrainingDays = averImplTrainingDays;
            solutionItem.averImplEffort = averImplEffort;
            solutionItem.averImplDuration = averImplDuration;
            solutionItem.averSizeImplTeam = averSizeImplTeam;
            solutionItem.averSaleCycle = averSaleCycle;
            solutionItem.noCustomers = noCustomers;
            solutionItem.smallImpl = smallImpl;
            solutionItem.largeImpl = largeImpl;
            solutionItem.smallImplTime = smallImplTime;
            solutionItem.largeImplTime = largeImplTime;
            solutionItem.smallImplTeamNo = smallImplTeamNo;
            solutionItem.largeImplTeamNo = largeImplTeamNo;

            solutionItem.solSite = solSite;

            //solutionItem.countryPriceEuro;

            solutionItem.refCustAvailForUse = refCustAvailForUse;
            solutionItem.totalAppBaseLinePrice = totalAppBaseLinePrice;
            solutionItem.appPriceEur = appPriceEur;
            solutionItem.hardwareCost = hardwareCost;
            solutionItem.hardwareCostEur = hardwareCostEur;
            solutionItem.averLicensePrice = averLicensePrice;
            solutionItem.averLicensePriceEur = averLicensePriceEur;
            solutionItem.addServiceCost = addServiceCost;
            solutionItem.addServicePriceEur = addServicePriceEur;
            solutionItem.implCost = implCost;
            solutionItem.implCostEur = implCostEur;
            solutionItem.sapDiscount = sapDiscount;
            solutionItem.dbUsed = dbUsed;
            solutionItem.SAPBusUsed = SAPBusUsed;
            solutionItem.SAPGUIUsed = SAPGUIUsed;
            solutionItem.compA1B1Used = compA1B1Used;
            solutionItem.thirdPartyUsed = thirdPartyUsed;
            solutionItem.thirdPartyName = thirdPartyName;
            solutionItem.otherIT = otherIT;
            solutionItem.addRemarks = addRemarks;
            solutionItem.solSAPMicroSite = solSAPMicroSite;

            // date
            if (lastPartRevieDate != null && !lastPartRevieDate.isEmpty()) {
                try {
                    tempDate = format.parse(lastPartRevieDate);
                    String value = tempDate.toString();
                    solutionItem.lastPartRevieDate = tempDate;
                } catch (ParseException ex) {
                }
            }

            solutionItem.reviewedBy = reviewedBy;
            solutionItem.profileAdded = profileAdded;
            //date
            solutionItem.dateCreated = new Date();

            solutionItem.modifiedBy = modifiedBy;

            //date
            solutionItem.dateUpdated = new Date();
            solutionItem.notificationProc = notificationProc;
            solutionItem.notificationText = notificationText;

            SolutionItemDAO.addSolutionItem(solutionItem);
            // childs
            SolutionUtil.updateSolutionSolFocus(solutionItem, sol_solFocusStr);
            SolutionUtil.updateSolutionCountryPriceEuro(solutionItem, sol_countryPriceEuro);
            SolutionUtil.updateSolutionGeographicCoverage(solutionItem, sol_geographic_coverage);
            SolutionUtil.updateSolutionIndustry(solutionItem, sol_industry);
            SolutionUtil.updateMySAPAllInOneVers(solutionItem, sol_mySAPAllInOneVers);
            SolutionUtil.updateMySAPOneProductVers(solutionItem, sol_mySAPOneProductVers);
            SolutionUtil.updateMaturity(solutionItem, sol_maturity);
            SolutionUtil.updateSolStatusByProvider(solutionItem, sol_statusByProvider);
            SolutionUtil.updateSolStatusBySAP(solutionItem, sol_statusBySAP);
            SolutionUtil.updateSolTargetCompSize(solutionItem, sol_targetCompSize);
            SolutionUtil.updateSolCategTarget(solutionItem, sol_categTarget);
            SolutionUtil.updateSolUserType(solutionItem, sol_userType);
            SolutionUtil.updateSolProgLang(solutionItem, sol_progLang);
            SolutionUtil.updateSolOS(solutionItem, sol_os);
            SolutionUtil.updateSolAioBased(solutionItem, sol_aioBased);
            //perform extra update
            SolutionItemDAO.updateSolutionItem(solutionItem);

        } else if (command.equals("edit")) {
            //user
            SolutionItem solutionItem = SolutionItemDAO.getSolutionItem(id);
            //public int companyId;
            solutionItem.solName = solName;
            solutionItem.solDesc = solDesc;
            solutionItem.partComSite = partComSite;
            //solutionItem.solFocus =    ;
            //solutionItem.solStatusPartner;
            //solutionItem.solStatusSAP;
            //solutionItem.solMaturity;
            //solutionItem.statusByProvider;
            //solutionItem.statusBySAP;
            //solutionItem.solUserType;

            //date
            if (sapCertSince != null && !sapCertSince.isEmpty()) {
                try {
                    tempDate = format.parse(sapCertSince);
                    String value = tempDate.toString();
                    System.out.println("date since = " + value);
                    solutionItem.sapCertSince = tempDate;
                } catch (ParseException ex) {
                }
            }

            if (lastReviewBySAP != null && !lastReviewBySAP.isEmpty()) {
                try {
                    tempDate = format.parse(lastReviewBySAP);
                    String value = tempDate.toString();
                    solutionItem.lastReviewBySAP = tempDate;
                } catch (ParseException ex) {
                }
            }

            solutionItem.averTrainEndUser = averTrainEndUser;
            solutionItem.averImplTrainingDays = averImplTrainingDays;
            solutionItem.averImplEffort = averImplEffort;
            solutionItem.averImplDuration = averImplDuration;
            solutionItem.averSizeImplTeam = averSizeImplTeam;
            solutionItem.averSaleCycle = averSaleCycle;
            solutionItem.noCustomers = noCustomers;
            solutionItem.smallImpl = smallImpl;
            solutionItem.largeImpl = largeImpl;
            solutionItem.smallImplTime = smallImplTime;
            solutionItem.largeImplTime = largeImplTime;
            solutionItem.smallImplTeamNo = smallImplTeamNo;
            solutionItem.largeImplTeamNo = largeImplTeamNo;

            solutionItem.solSite = solSite;

            //solutionItem.countryPriceEuro;

            solutionItem.refCustAvailForUse = refCustAvailForUse;
            solutionItem.totalAppBaseLinePrice = totalAppBaseLinePrice;
            solutionItem.appPriceEur = appPriceEur;
            solutionItem.hardwareCost = hardwareCost;
            solutionItem.hardwareCostEur = hardwareCostEur;
            solutionItem.averLicensePrice = averLicensePrice;
            solutionItem.averLicensePriceEur = averLicensePriceEur;
            solutionItem.addServiceCost = addServiceCost;
            solutionItem.addServicePriceEur = addServicePriceEur;
            solutionItem.implCost = implCost;
            solutionItem.implCostEur = implCostEur;
            solutionItem.sapDiscount = sapDiscount;
            solutionItem.dbUsed = dbUsed;
            solutionItem.SAPBusUsed = SAPBusUsed;
            solutionItem.SAPGUIUsed = SAPGUIUsed;
            solutionItem.compA1B1Used = compA1B1Used;
            solutionItem.thirdPartyUsed = thirdPartyUsed;
            solutionItem.thirdPartyName = thirdPartyName;
            solutionItem.otherIT = otherIT;
            solutionItem.addRemarks = addRemarks;
            solutionItem.solSAPMicroSite = solSAPMicroSite;

            // date
            if (lastPartRevieDate != null && !lastPartRevieDate.isEmpty()) {
                try {
                    tempDate = format.parse(lastPartRevieDate);
                    String value = tempDate.toString();
                    solutionItem.lastPartRevieDate = tempDate;
                } catch (ParseException ex) {
                }
            }

            solutionItem.reviewedBy = reviewedBy;
            solutionItem.profileAdded = profileAdded;
            //date
            solutionItem.dateCreated = new Date();

            solutionItem.modifiedBy = modifiedBy;

            //date
            solutionItem.dateUpdated = new Date();
            solutionItem.notificationProc = notificationProc;
            solutionItem.notificationText = notificationText;
            // Do update in main table
            SolutionUtil.updateSolutionSolFocus(solutionItem, sol_solFocusStr);
            SolutionUtil.updateSolutionCountryPriceEuro(solutionItem, sol_countryPriceEuro);
            SolutionUtil.updateSolutionGeographicCoverage(solutionItem, sol_geographic_coverage);
            SolutionUtil.updateSolutionIndustry(solutionItem, sol_industry);
            SolutionUtil.updateMySAPAllInOneVers(solutionItem, sol_mySAPAllInOneVers);
            SolutionUtil.updateMySAPOneProductVers(solutionItem, sol_mySAPOneProductVers);
            SolutionUtil.updateMaturity(solutionItem, sol_maturity);
            SolutionUtil.updateSolStatusByProvider(solutionItem, sol_statusByProvider);
            SolutionUtil.updateSolStatusBySAP(solutionItem, sol_statusBySAP);
            SolutionUtil.updateSolTargetCompSize(solutionItem, sol_targetCompSize);
            SolutionUtil.updateSolCategTarget(solutionItem, sol_categTarget);
            SolutionUtil.updateSolUserType(solutionItem, sol_userType);
            SolutionUtil.updateSolProgLang(solutionItem, sol_progLang);
            SolutionUtil.updateSolOS(solutionItem, sol_os);
            SolutionUtil.updateSolAioBased(solutionItem, sol_aioBased);

            SolutionItemDAO.updateSolutionItem(solutionItem);

        } else if (command.equals("delete")) {
            System.out.println("a facut delete ");
            System.out.println("a facut delete cu " + String.valueOf(id));

            SolutionItemDAO.deleteSolutionItem(id);
        }

    } catch (SQLException sqle) {
        throw new PortletException(sqle);
    }

}

From source file:com.concursive.connect.web.modules.documents.dao.FileFolder.java

/**
 * Gets the enteredString attribute of the FileFolder object
 *
 * @return The enteredString value/*w  w w .  j av  a2s  .  co m*/
 */
public String getEnteredString() {
    try {
        return DateFormat.getDateInstance(3).format(entered);
    } catch (NullPointerException e) {
    }
    return "";
}

From source file:com.agilejava.docbkx.maven.AbstractTransformerMojo.java

/**
 * Creates an XML Processing handler for the built-in docbkx <code>&lt;?eval?&gt;</code> PI. This PI resolves maven
 * properties and basic math formula.//from   ww w.ja  v a  2 s  .  c o m
 *
 * @param resolver The initial resolver to use.
 * @param reader   The source XML reader.
 * @return The XML PI filter.
 */
private PreprocessingFilter createPIHandler(EntityResolver resolver, XMLReader reader) {
    PreprocessingFilter filter = new PreprocessingFilter(reader);
    ProcessingInstructionHandler resolvingHandler = new ExpressionHandler(new VariableResolver() {

        public Object resolveVariable(String name) throws ELException {
            if ("date".equals(name)) {
                return DateFormat.getDateInstance(DateFormat.LONG).format(new Date());
            } else if ("project".equals(name)) {
                return getMavenProject();
            } else {
                return getMavenProject().getProperties().get(name);
            }
        }

    }, getLog());
    filter.setHandlers(Arrays.asList(new Object[] { resolvingHandler }));
    filter.setEntityResolver(resolver);
    return filter;
}

From source file:org.apache.click.servlet.MockRequest.java

/**
 * Get the given header as a date.//from  w  w  w.java  2  s  .c  om
 *
 * @param name The header name
 * @return The date, or -1 if header not found
 * @throws IllegalArgumentException If the header cannot be converted
 */
public long getDateHeader(final String name) throws IllegalArgumentException {
    String value = getHeader(name);
    if (value == null) {
        return -1;
    }

    DateFormat df = DateFormat.getDateInstance(DateFormat.FULL);
    try {
        return df.parse(value).getTime();
    } catch (ParseException e) {
        throw new IllegalArgumentException("Can't convert header to date " + name + ": " + value);
    }
}

From source file:com.cachirulop.moneybox.activity.MovementDetailActivity.java

/**
 * Update the get date field of the window with the value of the movement
 * object.// www .ja  va  2s. c  o  m
 */
private void updateGetDate() {
    TextView txt;

    txt = (TextView) findViewById(R.id.txtGetDate);
    if (_movement.getGetDate() != null) {
        txt.setText(DateFormat.getDateInstance(DateFormat.MEDIUM).format(_movement.getGetDate()));
    } else {
        txt.setText("");
    }
}

From source file:de.dreier.mytargets.features.statistics.StatisticsFragment.java

@NonNull
private Evaluator getEntryEvaluator(final List<Pair<Float, DateTime>> values) {
    boolean singleTraining = Stream.of(rounds).groupBy(r -> r.trainingId).count() == 1;

    Evaluator eval;//  ww  w  .j  a  va 2s  .co  m
    if (singleTraining) {
        eval = new Evaluator() {
            private DateFormat dateFormat = DateFormat.getTimeInstance(DateFormat.SHORT);

            @Override
            public long getXValue(List<Pair<Float, DateTime>> values, int i) {
                return values.get(i).second.getMillis() - values.get(0).second.getMillis();
            }

            @Override
            public String getXValueFormatted(float value) {
                final long diffToFirst = (long) value;
                return dateFormat.format(new Date(values.get(0).second.getMillis() + diffToFirst));
            }
        };
    } else {
        eval = new Evaluator() {
            private DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT);

            @Override
            public long getXValue(List<Pair<Float, DateTime>> values, int i) {
                return i;
            }

            @Override
            public String getXValueFormatted(float value) {
                return dateFormat.format(values.get((int) value).second.toDate());
            }
        };
    }
    return eval;
}

From source file:org.apache.wicket.protocol.http.mock.MockHttpServletRequest.java

/**
 * Get the given header as a date.//www . j a  v  a2  s . c o m
 * 
 * @param name
 *            The header name
 * @return The date, or -1 if header not found
 * @throws IllegalArgumentException
 *             If the header cannot be converted
 */
@Override
public long getDateHeader(final String name) throws IllegalArgumentException {
    String value = getHeader(name);
    if (value == null) {
        return -1;
    }

    DateFormat df = DateFormat.getDateInstance(DateFormat.FULL);
    try {
        return df.parse(value).getTime();
    } catch (ParseException e) {
        throw new IllegalArgumentException("Can't convert header to date " + name + ": " + value);
    }
}