Example usage for java.util Date getMinutes

List of usage examples for java.util Date getMinutes

Introduction

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

Prototype

@Deprecated
public int getMinutes() 

Source Link

Document

Returns the number of minutes past the hour represented by this date, as interpreted in the local time zone.

Usage

From source file:playground.jbischoff.carsharing.data.VBBRouteCatcher.java

private void run(Coord from, Coord to, long departureTime) {

    Locale locale = new Locale("en", "UK");
    String pattern = "###.000000";

    DecimalFormat df = (DecimalFormat) NumberFormat.getNumberInstance(locale);
    df.applyPattern(pattern);/*  ww  w. j a  v  a 2 s . c  o m*/

    // Construct data
    //X&Y coordinates must be exactly 8 digits, otherwise no proper result is given. They are swapped (x = long, y = lat)

    //Verbindungen 1-n bekommen; Laufweg, Reisezeit & Umstiege ermitteln
    String text = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"
            + "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"
            + "<ReqC accessId=\"JBischoff2486b558356fa9b81b1rzum\" ver=\"1.1\" requestId=\"7\" prod=\"SPA\" lang=\"DE\">"
            + "<ConReq>" + "<ReqT date=\"" + VBBDAY.format(departureTime) + "\" time=\""
            + VBBTIME.format(departureTime) + "\">" + "</ReqT>" + "<RFlags b=\"0\" f=\"1\" >" + "</RFlags>"
            + "<Start>" + "<Coord name=\"START\" x=\"" + df.format(from.getY()).replace(".", "") + "\" y=\""
            + df.format(from.getX()).replace(".", "") + "\" type=\"WGS84\"/>"
            + "<Prod  prod=\"1111000000000000\" direct=\"0\" sleeper=\"0\" couchette=\"0\" bike=\"0\"/>"
            + "</Start>" + "<Dest>" + "<Coord name=\"ZIEL\" x=\"" + df.format(to.getY()).replace(".", "")
            + "\" y=\"" + df.format(to.getX()).replace(".", "") + "\" type=\"WGS84\"/>" + "</Dest>"
            + "</ConReq>" + "</ReqC>";
    PostMethod post = new PostMethod("http://demo.hafas.de/bin/pub/vbb/extxml.exe/");
    post.setRequestBody(text);
    post.setRequestHeader("Content-type", "text/xml; charset=ISO-8859-1");
    HttpClient httpclient = new HttpClient();
    try {

        int result = httpclient.executeMethod(post);

        // Display status code
        //                     System.out.println("Response status code: " + result);

        // Display response
        //                     System.out.println("Response body: ");
        //                     System.out.println(post.getResponseBodyAsString());

        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document document = builder.parse(post.getResponseBodyAsStream());

        if (writeOutput) {
            BufferedWriter writer = IOUtils.getBufferedWriter(filename);
            Transformer transformer = TransformerFactory.newInstance().newTransformer();
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            //initialize StreamResult with File object to save to file
            StreamResult res = new StreamResult(writer);
            DOMSource source = new DOMSource(document);
            transformer.transform(source, res);
            writer.flush();
            writer.close();

        }

        Node connectionList = document.getFirstChild().getFirstChild().getFirstChild();
        NodeList connections = connectionList.getChildNodes();
        int amount = connections.getLength();
        for (int i = 0; i < amount; i++) {
            Node connection = connections.item(i);
            Node overview = connection.getFirstChild();
            ;

            while (!overview.getNodeName().equals("Overview")) {
                overview = overview.getNextSibling();
            }

            System.out.println(overview.getChildNodes().item(3).getTextContent());
            int transfers = Integer.parseInt(overview.getChildNodes().item(3).getTextContent());
            String time = overview.getChildNodes().item(4).getFirstChild().getTextContent().substring(3);
            System.out.println(time);
            Date rideTime = VBBDATE.parse(time);
            int seconds = rideTime.getHours() * 3600 + rideTime.getMinutes() * 60 + rideTime.getSeconds();
            System.out.println(seconds + "s; transfers: " + transfers);
            if (seconds < this.bestRideTime) {
                this.bestRideTime = seconds;
                this.bestTransfers = transfers;
            }
        }
    } catch (Exception e) {
        this.bestRideTime = -1;
        this.bestTransfers = -1;
    }

    finally {
        // Release current connection to the connection pool 
        // once you are done
        post.releaseConnection();
        post.abort();

    }

}

From source file:de.micromata.genome.gwiki.plugin.rogmp3_1_0.Track.java

public long getTime() {
    String l = get(LENGTH);/*from  w  w  w.j  a  v a2  s  . c  o m*/
    if (StringUtils.isBlank(l) == true) {
        return 0;
    }
    try {
        Date d = trackTimeFormat.get().parse(l);
        return d.getSeconds() + d.getMinutes() * 60 + d.getHours() * 3600;
    } catch (ParseException e) {
        System.out.println("cannot parse length: " + l);
        return 0;
    }
}

From source file:playground.jbischoff.taxi.berlin.supply.TaxiStatusDataAnalyser.java

@SuppressWarnings("deprecation")
public static void dumpTaxisInSystem(Matrices statusMatrices, String start, String end, String averagesFile,
        String taxisOverTimeFile) {
    Map<String, Double> taxisInSystem = new TreeMap<String, Double>();
    Map<String, Double> averageTaxisPerHour = new TreeMap<String, Double>();

    SimpleDateFormat hrs = new SimpleDateFormat("yyyyMMddHH");

    try {/*  w ww .  ja v a 2s . co m*/
        Date currentTime = STATUS_DATE_FORMAT.parse(start);
        Date endTime = STATUS_DATE_FORMAT.parse(end);

        double hourTaxis = 0.;
        double filesPerhr = 12;

        while (!currentTime.equals(endTime)) {
            Matrix matrix = statusMatrices.getMatrix(STATUS_DATE_FORMAT.format(currentTime));
            if (matrix == null) {
                System.err.println("id: " + STATUS_DATE_FORMAT.format(currentTime) + " not found");
                currentTime = getNextTime(currentTime);
                filesPerhr--;
                continue;
            }

            Iterable<Entry> entryIter = MatrixUtils.createEntryIterable(matrix);
            double totalTaxis = 0.;
            for (Entry e : entryIter) {
                totalTaxis += e.getValue();
                hourTaxis += e.getValue();
            }

            taxisInSystem.put(STATUS_DATE_FORMAT.format(currentTime), totalTaxis);

            if (currentTime.getMinutes() == 55) {
                double average = hourTaxis / filesPerhr;
                String t = hrs.format(currentTime);
                averageTaxisPerHour.put(t, average);
                hourTaxis = 0.;
                filesPerhr = 12.;
            }
            currentTime = getNextTime(currentTime);

        }

        dumpMapToFile(averageTaxisPerHour, averagesFile);
        dumpMapToFile(taxisInSystem, taxisOverTimeFile);
    } catch (ParseException e) {
        e.printStackTrace();
    }
}

From source file:com.dare2date.externeservice.lastfm.LastfmAPI.java

/**
 * Adds date data to an event./*from   w w  w  .  j  ava 2s .  c  o m*/
 * @param eventdata
 * @param event
 */
private void addDateToEventFromJSONData(JSONObject eventdata, LastfmEvent event) {
    try {
        Calendar date = Calendar.getInstance();
        Date _date = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss", Locale.ENGLISH)
                .parse(eventdata.get("startDate").toString());
        date.set(_date.getYear(), _date.getMonth(), _date.getDay(), _date.getHours(), _date.getMinutes(),
                _date.getSeconds());
        event.setStartDate(date);
    } catch (ParseException e) {
        e.printStackTrace();
    }
}

From source file:controllers.CNBCProxy.java

private static String CalculateDateFormat(long millis) {
    // Set helping arrays
    String[] monthArr = new String[12];
    String[] dayArr = new String[7];

    // Set month names
    monthArr[0] = "January";
    monthArr[1] = "February";
    monthArr[2] = "March";
    monthArr[3] = "April";
    monthArr[4] = "May";
    monthArr[5] = "June";
    monthArr[6] = "July";
    monthArr[7] = "August";
    monthArr[8] = "September";
    monthArr[9] = "October";
    monthArr[10] = "November";
    monthArr[11] = "December";

    // Set day names
    dayArr[0] = "Sunday";
    dayArr[1] = "Monday";
    dayArr[2] = "Tuesday";
    dayArr[3] = "Wednesday";
    dayArr[4] = "Thursday";
    dayArr[5] = "Friday";
    dayArr[6] = "Saturday";

    /** Create Date object with random date, in order to calculate date of article like 
    the "setTime()" function in Javascript (date since January 1, 1970 00:00:00 gmt)
    **///w  w  w . j  a v  a 2  s.  c  o m

    Date dateObj = new Date(92, 1, 10);

    // Add long number to get article's date
    dateObj.setTime(millis);

    StringBuilder date = new StringBuilder();
    date.append(dayArr[dateObj.getDay()]).append(", ").append(Integer.toString(dateObj.getDate())).append(" ")
            .append(monthArr[dateObj.getMonth()]).append(" ").append(Integer.toString(dateObj.getYear() + 1900))
            .append(" "); // 1900 added to year(see getYear() method's documentation)

    String hours;
    String midnight;

    if (dateObj.getHours() > 12) {
        if (dateObj.getHours() - 12 < 10) {
            hours = "0" + Integer.toString(dateObj.getHours() - 12);
        } else {
            hours = Integer.toString(dateObj.getHours() - 12);
        }
        midnight = "PM";
    } else {
        if (dateObj.getHours() < 10) {
            hours = "0" + Integer.toString(dateObj.getHours());
        } else {
            hours = Integer.toString(dateObj.getHours());
        }
        midnight = "AM";
    }

    date.append(hours).append(":").append(Integer.toString(dateObj.getMinutes()))
            .append(" " + midnight + " ET");

    return date.toString();
}

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

/**
 * ??2014624 17:23.// w ww .  j  a  v  a 2 s  .  c  om
 * 
 * @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:py.una.pol.karaku.test.test.DateUtilsTest.java

/**
 * Test method for//from   w  w w .j  ava 2 s. co m
 * {@link py.una.pol.karaku.util.DateUtils#cloneDate(java.util.Date)}.
 */
@SuppressWarnings("deprecation")
@Test
public void testGetCopy() {

    Date date = new Date();
    assertNotSame(date, cloneDate(date));
    assertEquals(date, cloneDate(date));
    Date copy = cloneDate(date);
    copy.setMinutes(copy.getMinutes() + 1);
    assertNotEquals(date, copy);
}

From source file:tds.tdsadmin.web.backingbean.DefaultBacking.java

public String getTime(Date date) {
    if (date != null)
        return date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
    else/*w  w  w.  j a v  a2  s . com*/
        return null;
}

From source file:com.liato.bankdroid.appwidget.AutoRefreshService.java

private boolean InsideUpdatePeriod() {
    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

    int start = prefs.getInt("refresh_start_minutes", 0);
    int stop = prefs.getInt("refresh_stop_minutes", 0);

    // If start is bigger than stop we always update. It should perhaps
    // be possible to set start to 17:00 and stop to 07:00 and have to
    // updates working from 17 to 07 around midnight
    if (start >= stop) {
        return true;
    }/*w w  w.  j a  v a2s  .  co  m*/

    Date now = new Date();
    int minutesSinceMidnight = now.getHours() * 60 + now.getMinutes();
    return minutesSinceMidnight > start && minutesSinceMidnight < stop;
}

From source file:gov.nih.nci.ess.ae.GridToDomainObjectConverter.java

/**
 * Will transfer data from the given grid-based {@link AdverseEvent} to the
 * given {@link gov.nih.nci.cabig.caaers.domain.AdverseEvent} domain object.
 * /* w  ww  .  ja v  a  2 s.  c  o m*/
 * @param gridAe
 * @param caaersAe
 * @return
 * @throws NumberFormatException
 * @throws CaaersSystemException
 */
public void convertAdverseEvent(AdverseEvent gridAe, gov.nih.nci.cabig.caaers.domain.AdverseEvent caaersAe)
        throws NumberFormatException, CaaersSystemException {
    if (gridAe.getIdentifier() != null) {
        caaersAe.setId(Integer.parseInt(gridAe.getIdentifier().getExtension()));
    }
    if (gridAe.getComment() != null) {
        caaersAe.setComments(gridAe.getComment().getValue());
    }
    if (gridAe.getResolutionDate() != null) {
        caaersAe.setEndDate(convertToDate(gridAe.getResolutionDate()));
    }
    if (gridAe.getOnsetDate() != null) {
        Date startDate = convertToDate(gridAe.getOnsetDate());
        TimeValue t = new TimeValue();
        t.setHour(startDate.getHours());
        t.setMinute(startDate.getMinutes());
        System.out.println(t.getHourString() + ":" + t.getMinuteString());
        if (t != null)
            caaersAe.setEventApproximateTime(t);
    }

    if (gridAe.getLocationDescription() != null) {
        caaersAe.setEventLocation(gridAe.getLocationDescription().getValue());
    }
    if (gridAe.getExpectedIndicator() != null) {
        caaersAe.setExpected(gridAe.getExpectedIndicator().getValue());
    }
    if (gridAe.getGradeCode() != null) {
        caaersAe.setGrade(Grade.getByCode(Integer.parseInt(gridAe.getGradeCode().getCode())));
    }
    if (gridAe.getReportedDate() != null) {
        caaersAe.setGradedDate(convertToDate(gridAe.getReportedDate()));
    }
    if (gridAe.getHospitalizationRequiredIndicator() != null) {
        if (gridAe.getHospitalizationRequiredIndicator().getValue()) {
            caaersAe.setHospitalization(Hospitalization.YES);
        } else {
            caaersAe.setHospitalization(Hospitalization.NO);
        }
    }
    if (gridAe.getPostReportUpdateDate() != null) {
        caaersAe.setPostSubmissionUpdatedDate(convertToDate(gridAe.getPostReportUpdateDate()));
    }
    if (gridAe.getOnsetDate() != null) {
        caaersAe.setStartDate(convertToDate(gridAe.getOnsetDate()));
    }

    if (gridAe.getResult() != null) {
        caaersAe.setDetailsForOther(gridAe.getResult().getCode());
    }

    if (gridAe.getProbabilityCode() != null) {
        caaersAe.setAttributionSummary(
                Attribution.getByCode(Integer.parseInt(gridAe.getProbabilityCode().getCode())));
    }

    if (gridAe.getAdverseEventCtcTerm() != null) {
        /*
         * AdverseEventCtcTerm adverseEventCtcTerm = new
         * AdverseEventCtcTerm(); CtcTerm ctcTerm = new CtcTerm(); if
         * (gridAe.getAdverseEventCtcTerm().getCtepTerm().getOriginalText()
         * != null) {
         * ctcTerm.setCtepTerm(gridAe.getAdverseEventCtcTerm().getCtepTerm
         * ().getOriginalText().getValue()); } if
         * (gridAe.getAdverseEventCtcTerm().getCtepTerm().getCode() != null)
         * {
         * ctcTerm.setCtepCode(gridAe.getAdverseEventCtcTerm().getCtepTerm(
         * ).getCode()); } adverseEventCtcTerm.setCtcTerm(ctcTerm);
         * caaersAe.setAdverseEventCtcTerm(adverseEventCtcTerm);
         */
        this.populateCtcTerm(gridAe, caaersAe);
    }

    if (gridAe.getOtherMeddra() != null /*
                                        * &&
                                        * caaersAe.getLowLevelTerm()==null
                                        */) {
        /*
         * if (gridAe.getOtherMeddra() != null) {
         * gov.nih.nci.cabig.caaers.domain.meddra.LowLevelTerm lowLevelTerm
         * = new gov.nih.nci.cabig.caaers.domain.meddra.LowLevelTerm(); if
         * (gridAe.getOtherMeddra().getMeddraCode() != null) {
         * lowLevelTerm.setMeddraCode
         * (gridAe.getOtherMeddra().getMeddraCode().toString()); } if
         * (gridAe.getOtherMeddra().getMeddraTerm() != null) {
         * lowLevelTerm.setMeddraTerm
         * (gridAe.getOtherMeddra().getMeddraTerm().toString()); }
         * AdverseEventMeddraLowLevelTerm adverseEventMeddraLowLevelTerm =
         * new AdverseEventMeddraLowLevelTerm();
         * adverseEventMeddraLowLevelTerm.setLowLevelTerm(lowLevelTerm);
         * caaersAe
         * .setAdverseEventMeddraLowLevelTerm(adverseEventMeddraLowLevelTerm
         * ); }
         */
        this.populateLowLevelTerm(gridAe.getOtherMeddra(), caaersAe);
    }

    caaersAe.getOutcomes().clear();
    if (gridAe.getAdverseEventSeriousness() != null) {
        populateOutcomes(gridAe.getAdverseEventSeriousness(), caaersAe);
    }

}