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:org.infoscoop.request.filter.rss.RssHandler.java

/**
 * Return the date whose form is "yyyy/MM/dd HH:mm:ss" -> obsolute
 * javascript Date :An argument form of the object instance.
 * Return the date whose form is "yyyy,MM,dd,HH,mm,ss".
 * //from w  w  w. j  av a  2s .c  om
 * @param date
 * @return
 */
public static String getFullDate(Date date) {
    if (date == null) {
        return null;
    }

    try {
        //         return formatFullDate.format(date);
        return (date.getYear() + 1900) + "," + date.getMonth() + "," + date.getDate() + "," + date.getHours()
                + "," + date.getMinutes() + "," + date.getSeconds();
    } catch (IllegalArgumentException e1) {
        return null;
    }
}

From source file:com.opendesign.utils.Day.java

@SuppressWarnings("deprecation")
public static String addMinutes(String dateTime, int min) {

    Date date = getDateWithTyphoonFormatString(dateTime);
    date.setMinutes(date.getMinutes() + min);

    return Day.toStringAsyyyyMMddHHmmss(date.getTime());

}

From source file:org.sonar.server.filters.DateCriterionTest.java

@Test
public void testDaysAgo() {
    DateCriterion criterion = new DateCriterion().setDate(3);
    Date date = criterion.getDate();
    assertThat(date.getMinutes(), is(0));
    assertThat(date.getHours(), is(0));/*from   w w w  .jav a 2s  . c  o m*/
    assertThat(DateUtils.isSameDay(date, DateUtils.addDays(new Date(), -3)), is(true));
}

From source file:org.metawatch.manager.Monitors.java

private static synchronized void updateWeatherDataWunderground(Context context) {
    try {/*from   w w  w .  ja va 2  s  . co  m*/

        if (WeatherData.updating)
            return;

        long currentTime = System.currentTimeMillis();

        // Prevent weather updating more frequently than every 5 mins
        if (WeatherData.timeStamp != 0 && WeatherData.received) {

            long diff = currentTime - WeatherData.timeStamp;
            if (diff < 5 * 60 * 1000) {
                if (Preferences.logging)
                    Log.d(MetaWatch.TAG, "Skipping weather update - updated less than 5m ago");
                Idle.updateIdle(context, true);
                return;
            }
        }

        WeatherData.updating = true;

        if (Preferences.logging)
            Log.d(MetaWatch.TAG, "Monitors.updateWeatherDataWunderground(): start");

        if ((LocationData.received || (Preferences.weatherGeolocation == false))
                && Preferences.wundergroundKey != "") {

            String weatherLocation = Double.toString(LocationData.latitude) + ","
                    + Double.toString(LocationData.longitude);
            if (Preferences.weatherGeolocation == false)
                weatherLocation = Preferences.weatherCity.replace(",", "").replace(" ", "%20");

            String forecastQuery = "";
            boolean hasForecast = false;

            long diff = currentTime - WeatherData.forecastTimeStamp;
            if (WeatherData.forecast == null || (diff > 3 * 60 * 60 * 1000)) {
                // Only update forecast every three hours
                forecastQuery = "forecast10day/astronomy/";
                hasForecast = true;
            }

            String requestUrl = "http://api.wunderground.com/api/" + Preferences.wundergroundKey
                    + "/geolookup/conditions/" + forecastQuery + "q/" + weatherLocation + ".json";

            if (Preferences.logging)
                Log.d(MetaWatch.TAG, "Request: " + requestUrl);

            JSONObject json = getJSONfromURL(requestUrl);

            JSONObject location = json.getJSONObject("location");
            JSONObject current = json.getJSONObject("current_observation");

            if (hasForecast) {
                JSONObject moon = json.getJSONObject("moon_phase");
                JSONObject sunrise = moon.getJSONObject("sunrise");
                WeatherData.sunriseH = sunrise.getInt("hour");
                WeatherData.sunriseM = sunrise.getInt("minute");
                JSONObject sunset = moon.getJSONObject("sunset");
                WeatherData.sunsetH = sunset.getInt("hour");
                WeatherData.sunsetM = sunset.getInt("minute");

                WeatherData.moonPercentIlluminated = moon.getInt("percentIlluminated");
                WeatherData.ageOfMoon = moon.getInt("ageOfMoon");
            }

            boolean isDay = true;

            Date dt = new Date();
            int hours = dt.getHours();
            int minutes = dt.getMinutes();

            if ((hours < WeatherData.sunriseH)
                    || (hours == WeatherData.sunriseH && minutes < WeatherData.sunriseM)
                    || (hours > WeatherData.sunsetH)
                    || (hours == WeatherData.sunsetH && minutes > WeatherData.sunsetM)) {
                isDay = false;
            }

            WeatherData.locationName = location.getString("city");
            WeatherData.condition = current.getString("weather");
            WeatherData.icon = getIconWunderground(current.getString("icon"), isDay);

            if (Preferences.weatherCelsius) {
                WeatherData.temp = current.getString("temp_c");
            } else {
                WeatherData.temp = current.getString("temp_f");
            }

            if (hasForecast) {
                JSONObject forecast = json.getJSONObject("forecast");
                JSONArray forecastday = forecast.getJSONObject("simpleforecast").getJSONArray("forecastday");

                int days = forecastday.length();
                WeatherData.forecast = new Forecast[days];

                for (int i = 0; i < days; ++i) {
                    WeatherData.forecast[i] = m.new Forecast();
                    JSONObject day = forecastday.getJSONObject(i);
                    JSONObject date = day.getJSONObject("date");

                    WeatherData.forecast[i].icon = getIconWunderground(day.getString("icon"), true);
                    WeatherData.forecast[i].day = date.getString("weekday_short");
                    if (Preferences.weatherCelsius) {
                        WeatherData.forecast[i].tempLow = day.getJSONObject("low").getString("celsius");
                        WeatherData.forecast[i].tempHigh = day.getJSONObject("high").getString("celsius");
                    } else {
                        WeatherData.forecast[i].tempLow = day.getJSONObject("low").getString("fahrenheit");
                        WeatherData.forecast[i].tempHigh = day.getJSONObject("high").getString("fahrenheit");
                    }
                }

                WeatherData.forecastTimeStamp = System.currentTimeMillis();
            }

            WeatherData.celsius = Preferences.weatherCelsius;

            WeatherData.received = true;

            Idle.updateIdle(context, true);
            MetaWatchService.notifyClients();
            WeatherData.timeStamp = System.currentTimeMillis();
        }

    } catch (Exception e) {
        if (Preferences.logging)
            Log.e(MetaWatch.TAG, "Exception while retreiving weather", e);
    } finally {
        if (Preferences.logging)
            Log.d(MetaWatch.TAG, "Monitors.updateWeatherData(): finish");

        WeatherData.updating = false;
    }
}

From source file:eionet.meta.exports.ods.Ods.java

/**
 * Returns date.//from   w  ww.ja v a2s . c o m
 *
 * @param timestamp
 *            time stamp
 *
 * @return date as a string
 */
public static String getDate(long timestamp) {

    Date date = new Date(timestamp);
    String year = String.valueOf(1900 + date.getYear());
    String month = String.valueOf(date.getMonth() + 1);
    month = (month.length() < 2) ? ("0" + month) : month;
    String day = String.valueOf(date.getDate());
    day = (day.length() < 2) ? ("0" + day) : day;
    String hours = String.valueOf(date.getHours());
    hours = (hours.length() < 2) ? ("0" + hours) : hours;
    String minutes = String.valueOf(date.getMinutes());
    minutes = (minutes.length() < 2) ? ("0" + minutes) : minutes;
    String seconds = String.valueOf(date.getSeconds());
    seconds = (seconds.length() < 2) ? ("0" + seconds) : seconds;

    String time = year;
    time = time + "-" + month;
    time = time + "-" + day;
    time = time + "T" + hours;
    time = time + ":" + minutes;
    time = time + ":" + seconds;

    return time;
}

From source file:org.sonar.server.filters.DateCriterionTest.java

@Test
public void ignoreTime() {
    DateCriterion criterion = new DateCriterion().setDate(3);
    Date date = criterion.getDate();
    assertThat(date.getHours(), is(0));//  ww  w  . j  a  v a 2s. c  o m
    assertThat(date.getMinutes(), is(0));
}

From source file:com.yj.smarthome.activity.control.MainControlActivity.java

/**
 * ??2014624 17:23.//from  w ww . j  a v a 2s.  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.spike1.web.controller.Spike1ManageController.java

public String getTimestampString(Date date) {
    return "" + date.getYear() + date.getMonth() + date.getDate() + date.getHours()
            + (date.getMinutes() - date.getMinutes() % 2);
}

From source file:com.alliander.osgp.webdevicesimulator.service.OslpChannelHandler.java

private static Message createGetActualPowerUsageResponse() {
    // yyyyMMddhhmmss z
    final SimpleDateFormat utcTimeFormat = new SimpleDateFormat("yyyyMMddHHmmss");
    utcTimeFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

    final Date currentDateTime = new Date();
    final String utcTimestamp = utcTimeFormat.format(currentDateTime);

    @SuppressWarnings("deprecation")
    final int actualConsumedPower = currentDateTime.getMinutes();

    return Oslp.Message.newBuilder()
            .setGetActualPowerUsageResponse(GetActualPowerUsageResponse.newBuilder()
                    .setPowerUsageData(PowerUsageData.newBuilder().setRecordTime(utcTimestamp)
                            .setMeterType(MeterType.P1).setTotalConsumedEnergy(actualConsumedPower * 2L)
                            .setActualConsumedPower(actualConsumedPower)
                            .setPsldData(PsldData.newBuilder().setTotalLightingHours(actualConsumedPower * 3))
                            .setSsldData(SsldData.newBuilder().setActualCurrent1(1).setActualCurrent2(2)
                                    .setActualCurrent3(3).setActualPower1(1).setActualPower2(2)
                                    .setActualPower3(3).setAveragePowerFactor1(1).setAveragePowerFactor2(2)
                                    .setAveragePowerFactor3(3)
                                    .addRelayData(Oslp.RelayData.newBuilder()
                                            .setIndex(ByteString.copyFrom(new byte[] { 1 }))
                                            .setTotalLightingMinutes(480))
                                    .addRelayData(Oslp.RelayData
                                            .newBuilder().setIndex(ByteString.copyFrom(new byte[] { 2 }))
                                            .setTotalLightingMinutes(480))
                                    .addRelayData(Oslp.RelayData.newBuilder()
                                            .setIndex(ByteString.copyFrom(new byte[] { 3 }))
                                            .setTotalLightingMinutes(480))
                                    .addRelayData(Oslp.RelayData.newBuilder()
                                            .setIndex(ByteString.copyFrom(new byte[] { 4 }))
                                            .setTotalLightingMinutes(480))))
                    .setStatus(Oslp.Status.OK))
            .build();/*  w w  w.j  a v  a  2s  . co m*/
}

From source file:org.openmrs.web.servlet.ShowGraphServletTest.java

/**
 * @see ShowGraphServlet#getToDate(String)
 *//*from  ww w . j av  a 2  s .c o m*/
@Test
@Verifies(value = "should set hour minute and second to zero", method = "getToDate(String)")
public void getToDate_shouldSetHourMinuteAndSecondToZero() throws Exception {
    Date toDate = new ShowGraphServlet().getToDate(Long.toString(new Date().getTime()));
    Assert.assertEquals(0, toDate.getHours());
    Assert.assertEquals(0, toDate.getMinutes());
    Assert.assertEquals(0, toDate.getSeconds());
}