Java Code Examples for java.util.Date#getMinutes()

The following examples show how to use java.util.Date#getMinutes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Time_12_LocalDateTime_t.java    From coming with MIT License 6 votes vote down vote up
/**
 * Constructs a LocalDateTime from a <code>java.util.Date</code>
 * using exactly the same field values.
 * <p>
 * Each field is queried from the Date and assigned to the LocalDateTime.
 * This is useful if you have been using the Date as a local date,
 * ignoring the zone.
 * <p>
 * One advantage of this method is that this method is unaffected if the
 * version of the time zone data differs between the JDK and Joda-Time.
 * That is because the local field values are transferred, calculated using
 * the JDK time zone data and without using the Joda-Time time zone data.
 * <p>
 * This factory method always creates a LocalDateTime with ISO chronology.
 *
 * @param date  the Date to extract fields from, not null
 * @return the created local date-time, not null
 * @throws IllegalArgumentException if the calendar is null
 * @throws IllegalArgumentException if the date is invalid for the ISO chronology
 */
@SuppressWarnings("deprecation")
public static LocalDateTime fromDateFields(Date date) {
    if (date == null) {
        throw new IllegalArgumentException("The date must not be null");
    }
    if (date.getTime() < 0) {
        // handle years in era BC
        GregorianCalendar cal = new GregorianCalendar();
        cal.setTime(date);
        return fromCalendarFields(cal);
    }
    return new LocalDateTime(
        date.getYear() + 1900,
        date.getMonth() + 1,
        date.getDate(),
        date.getHours(),
        date.getMinutes(),
        date.getSeconds(),
        (((int) (date.getTime() % 1000)) + 1000) % 1000
    );
}
 
Example 2
Source File: AlbianRemoteUNIDService.java    From Albianj2 with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void unpack(BigInteger bi, RefArg<Timestamp> time,
                   RefArg<Integer> sed, RefArg<Integer> idx) {
    long r32 = bi.divide(new BigInteger("1000000000")).longValue();
    int next = bi.divide(new BigInteger("100")).intValue();
    int i = bi.modInverse(new BigInteger("100")).intValue();
    if (null != time) {
        Date dt = AlbianDateTime.dateAddSeconds(2015, 1, 1, r32);
        @SuppressWarnings("deprecation")
        Timestamp tt = new Timestamp(dt.getYear(), dt.getMonth(),
                dt.getDate(), dt.getHours(), dt.getMinutes(),
                dt.getSeconds(), 0);
        time.setValue(tt);
    }
    if (null != sed)
        sed.setValue(next);
    if (null != idx)
        idx.setValue(i);
}
 
Example 3
Source File: LocalDateTime.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs a LocalDateTime from a <code>java.util.Date</code>
 * using exactly the same field values.
 * <p>
 * Each field is queried from the Date and assigned to the LocalDateTime.
 * This is useful if you have been using the Date as a local date,
 * ignoring the zone.
 * <p>
 * One advantage of this method is that this method is unaffected if the
 * version of the time zone data differs between the JDK and Joda-Time.
 * That is because the local field values are transferred, calculated using
 * the JDK time zone data and without using the Joda-Time time zone data.
 * <p>
 * This factory method always creates a LocalDateTime with ISO chronology.
 *
 * @param date  the Date to extract fields from, not null
 * @return the created local date-time, not null
 * @throws IllegalArgumentException if the calendar is null
 * @throws IllegalArgumentException if the date is invalid for the ISO chronology
 */
@SuppressWarnings("deprecation")
public static LocalDateTime fromDateFields(Date date) {
    if (date == null) {
        throw new IllegalArgumentException("The date must not be null");
    }
    if (date.getTime() < 0) {
        // handle years in era BC
        GregorianCalendar cal = new GregorianCalendar();
        cal.setTime(date);
        return fromCalendarFields(cal);
    }
    return new LocalDateTime(
        date.getYear() + 1900,
        date.getMonth() + 1,
        date.getDate(),
        date.getHours(),
        date.getMinutes(),
        date.getSeconds(),
        (((int) (date.getTime() % 1000)) + 1000) % 1000
    );
}
 
Example 4
Source File: CustomAnalogClock.java    From TvLauncher with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
private void onTimeChanged() {
    int hour = 0;
    int minute = 0;
    int second = 0;
    if (bGMTTime) {
        Date gmtDate = getGmtTimer();
        hour = gmtDate.getHours();
        minute = gmtDate.getMinutes();
        second = gmtDate.getSeconds() + 1;
    } else {
        Date curDate = Calendar.getInstance().getTime();
        hour = curDate.getHours();
        minute = curDate.getMinutes();
        second = curDate.getSeconds() + 1;
    }

    mSeconds = second;
    mMinutes = minute + second / 60.0f;
    mHour = hour + mMinutes / 60.0f;

    mChanged = true;
}
 
Example 5
Source File: LocalDateTime.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs a LocalDateTime from a <code>java.util.Date</code>
 * using exactly the same field values.
 * <p>
 * Each field is queried from the Date and assigned to the LocalDateTime.
 * This is useful if you have been using the Date as a local date,
 * ignoring the zone.
 * <p>
 * One advantage of this method is that this method is unaffected if the
 * version of the time zone data differs between the JDK and Joda-Time.
 * That is because the local field values are transferred, calculated using
 * the JDK time zone data and without using the Joda-Time time zone data.
 * <p>
 * This factory method always creates a LocalDateTime with ISO chronology.
 *
 * @param date  the Date to extract fields from, not null
 * @return the created local date-time, not null
 * @throws IllegalArgumentException if the calendar is null
 * @throws IllegalArgumentException if the date is invalid for the ISO chronology
 */
@SuppressWarnings("deprecation")
public static LocalDateTime fromDateFields(Date date) {
    if (date == null) {
        throw new IllegalArgumentException("The date must not be null");
    }
    if (date.getTime() < 0) {
        // handle years in era BC
        GregorianCalendar cal = new GregorianCalendar();
        cal.setTime(date);
        return fromCalendarFields(cal);
    }
    return new LocalDateTime(
        date.getYear() + 1900,
        date.getMonth() + 1,
        date.getDate(),
        date.getHours(),
        date.getMinutes(),
        date.getSeconds(),
        (((int) (date.getTime() % 1000)) + 1000) % 1000
    );
}
 
Example 6
Source File: GraphActivity.java    From ncalc with GNU General Public License v3.0 5 votes vote down vote up
private void saveImage() {
    try {
        File root = Environment.getExternalStorageDirectory();
        if (root.canWrite()) {
            Date d = new Date();
            File imageLoc = new File(root, "com/duy/example/com.duy.calculator/graph/" + d.getMonth() + d.getDay() + d.getHours() + d.getMinutes() + d.getSeconds() + ".png");
            FileOutputStream out = new FileOutputStream(imageLoc);
        } else {
            Toast.makeText(GraphActivity.this, getString(R.string.cannotwrite), Toast.LENGTH_LONG).show();
        }
    } catch (Exception e) {
        Toast.makeText(GraphActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
    }
}
 
Example 7
Source File: ZioEntry.java    From fdroidclient with GNU General Public License v3.0 5 votes vote down vote up
public void setTime(long time) {
    Date d = new Date(time);
    long dtime;
    int year = d.getYear() + 1900;
    if (year < 1980) {
        dtime = (1 << 21) | (1 << 16);
    } else {
        dtime = (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
                d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
                d.getSeconds() >> 1;
    }

    modificationDate = (short) (dtime >> 16);
    modificationTime = (short) (dtime & 0xFFFF);
}
 
Example 8
Source File: ZipUtils.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Converts Java time to DOS time.
 */
@SuppressWarnings("deprecation") // Use of date methods
public static long javaToDosTime(long time) {
    Date d = new Date(time);
    int year = d.getYear() + 1900;
    if (year < 1980) {
        return (1 << 21) | (1 << 16);
    }
    return (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
           d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
           d.getSeconds() >> 1;
}
 
Example 9
Source File: ZipUtils.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static long javaToDosTime(long time) {
    Date d = new Date(time);
    int year = d.getYear() + 1900;
    if (year < 1980) {
        return (1 << 21) | (1 << 16);
    }
    return (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
           d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
           d.getSeconds() >> 1;
}
 
Example 10
Source File: Time.java    From MissZzzReader with Apache License 2.0 5 votes vote down vote up
public void init(com.zhao.myreader.entity.Date date){
    Date date1 = new Date();
    year = date.getYear();
    month = date.getMonth();
    this.date = date.getDate();
    hour = date1.getHours();
    minute = date1.getMinutes();
    second = 0;
}
 
Example 11
Source File: ExportChartVolume.java    From High-Frequency-Data-Order-Book-Analyser with GNU General Public License v2.0 5 votes vote down vote up
public void endExport() throws IOException, WriteException {

        Date mydate = new Date();
        //String file = "C:/Users/Nicolas_2/Desktop/bachir V4/Nico/Export/TemplateChart-Spread-" + mydate.getHours() + "h" + mydate.getMinutes() + ".xls";
        String file = "Export\\Volume\\TemplateChart-Volume" + mydate.getHours() + "h" + mydate.getMinutes() + ".xls";
        File f = new File(file);
        f.getParentFile().mkdir();
        f.createNewFile();

        try {
            outWorkBook = Workbook.createWorkbook(f);
            out = outWorkBook.createSheet("Data", 0);
            // Récupération de l'onglet courant (le premier onglet)
            out = outWorkBook.getSheet(0);
            Label labelD = new Label(0, 0, "Date");
            Label labelP = new Label(1, 0, "Price");
            Label labelS = new Label(2, 0, "Shares");

            //Ajout des cellules 
            out.addCell(labelD);
            out.addCell(labelP);
            out.addCell(labelS);

        } catch (IOException ex) {
            Logger.getLogger(ExportChartSpread.class.getName()).log(Level.SEVERE, null, ex);

        }
        this.WriteData();
        outWorkBook.write();

        outWorkBook.close();

    }
 
Example 12
Source File: ZipUtils.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static long javaToDosTime(long time) {
    Date d = new Date(time);
    int year = d.getYear() + 1900;
    if (year < 1980) {
        return (1 << 21) | (1 << 16);
    }
    return (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
           d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
           d.getSeconds() >> 1;
}
 
Example 13
Source File: AttendanceService.java    From lemon with Apache License 2.0 5 votes vote down vote up
public boolean isAfter(Date now) {
    AttendanceRule attendanceRule = this.findAttendanceRule();

    int hourOffset = attendanceRule.getEndHour() - now.getHours();
    int minuteOffset = ((hourOffset * 60) + attendanceRule.getEndMinute())
            - now.getMinutes();

    return minuteOffset < attendanceRule.getEndOffset();
}
 
Example 14
Source File: ZipUtils.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Converts Java time to DOS time.
 */
@SuppressWarnings("deprecation") // Use of date methods
public static long javaToDosTime(long time) {
    Date d = new Date(time);
    int year = d.getYear() + 1900;
    if (year < 1980) {
        return (1 << 21) | (1 << 16);
    }
    return (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
           d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
           d.getSeconds() >> 1;
}
 
Example 15
Source File: ZipUtils.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Converts Java time to DOS time.
 */
@SuppressWarnings("deprecation") // Use of date methods
private static long javaToDosTime(long time) {
    Date d = new Date(time);
    int year = d.getYear() + 1900;
    if (year < 1980) {
        return ZipEntry.DOSTIME_BEFORE_1980;
    }
    return (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
           d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
           d.getSeconds() >> 1;
}
 
Example 16
Source File: ZipUtils.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Converts Java time to DOS time.
 */
@SuppressWarnings("deprecation") // Use of date methods
private static long javaToDosTime(long time) {
    Date d = new Date(time);
    int year = d.getYear() + 1900;
    if (year < 1980) {
        return ZipEntry.DOSTIME_BEFORE_1980;
    }
    return (year - 1980) << 25 | (d.getMonth() + 1) << 21 |
           d.getDate() << 16 | d.getHours() << 11 | d.getMinutes() << 5 |
           d.getSeconds() >> 1;
}
 
Example 17
Source File: JudgeNotifyTask.java    From uavstack with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private String genJudgedKey(Slice slice) {

    Date d = new Date(slice.getTime());
    return RNJUDGE_PREFIX + slice.getKey() + "_" + d.getMinutes();
}
 
Example 18
Source File: DateUtil.java    From iSCAU-Android with GNU General Public License v3.0 4 votes vote down vote up
public String getCurrentTime() {
    Date currentTime = new Date();
    String TimeString = currentTime.getHours() + ":"
            + currentTime.getMinutes();
    return TimeString;
}
 
Example 19
Source File: HourMinuteSecond.java    From fenixedu-academic with GNU Lesser General Public License v3.0 3 votes vote down vote up
/**
 * Constructs a HourMinuteSecond from a <code>java.util.Date</code> using
 * exactly the same field values avoiding any time zone effects.
 * <p>
 * Each field is queried from the Date and assigned to the HourMinuteSecond. This is useful if you have been using the Date as
 * a local date, ignoing the zone.
 * <p>
 * This factory method always creates a HourMinuteSecond with ISO chronology.
 * 
 * @param date
 *            the Date to extract fields from
 * @return the created HourMinuteSecond
 * @throws IllegalArgumentException
 *             if the calendar is null
 * @throws IllegalArgumentException
 *             if the date is invalid for the ISO chronology
 */
public static HourMinuteSecond fromDateFields(Date date) {
    if (date == null) {
        throw new IllegalArgumentException("The date must not be null");
    }
    return new HourMinuteSecond(date.getHours(), date.getMinutes(), date.getSeconds());
}
 
Example 20
Source File: VCalendar.java    From calendar-component with Apache License 2.0 2 votes vote down vote up
/**
 * Is the date at midnight
 *
 * @param date
 *            The date to check
 *
 * @return true, if it's midnight
 */
@SuppressWarnings("deprecation")
public static boolean isMidnight(Date date) {
    return (date.getHours() == 0 && date.getMinutes() == 0
            && date.getSeconds() == 0);
}