Android Open Source - RadioRake Date Utils






From Project

Back to project page RadioRake.

License

The source code is released under:

GNU General Public License

If you think the Android project RadioRake listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.asp.radiorake.utils;
//from w  w  w . j  a v a  2 s  .co m
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

public class DateUtils {

    public static long addDay(long dateTimeMillis) {
        Calendar calendar = new GregorianCalendar();
        calendar.setTimeInMillis(dateTimeMillis);
        calendar.add(Calendar.DATE, 1);
        return calendar.getTimeInMillis();
    }

    public static long addWeek(long dateTimeMillis) {
        Calendar calendar = new GregorianCalendar();
        calendar.setTimeInMillis(dateTimeMillis);
        calendar.add(Calendar.DATE, 7);
        return calendar.getTimeInMillis();
    }

    public static String getDateTimeString(long dateTime) {
        SimpleDateFormat format = new SimpleDateFormat("HH:mm dd/MM/yy");
        StringBuilder dateString = new StringBuilder(format.format(dateTime));
        return dateString.toString();
    }

    public static int getYear(long dateTimeMillis) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy");
        StringBuilder dateString = new StringBuilder(format.format(dateTimeMillis));
        return Integer.parseInt(dateString.toString());
    }

    public static int getMonth(long dateTimeMillis) {
        SimpleDateFormat format = new SimpleDateFormat("MM");
        StringBuilder dateString = new StringBuilder(format.format(dateTimeMillis));
        return Integer.parseInt(dateString.toString()) - 1;
    }

    public static int getDay(long dateTimeMillis) {
        SimpleDateFormat format = new SimpleDateFormat("dd");
        StringBuilder dateString = new StringBuilder(format.format(dateTimeMillis));
        return Integer.parseInt(dateString.toString());
    }

    public static int getHour(long dateTimeMillis) {
        SimpleDateFormat format = new SimpleDateFormat("HH");
        StringBuilder dateString = new StringBuilder(format.format(dateTimeMillis));
        return Integer.parseInt(dateString.toString());
    }

    public static int getMinute(long dateTimeMillis) {
        SimpleDateFormat format = new SimpleDateFormat("mm");
        StringBuilder dateString = new StringBuilder(format.format(dateTimeMillis));
        return Integer.parseInt(dateString.toString());
    }

    public static String getHoursAndMinutes(long dateTimeMillis) {
        String format = String.format("%%0%dd", 2);
        long elapsedTime = dateTimeMillis / 1000;
        String minutes = String.format(format, (elapsedTime % 3600) / 60);
        String hours = String.format(format, elapsedTime / 3600);
        return hours + ":" + minutes;
    }
}




Java Source Code List

com.asp.radiorake.AddNewScheduledRecordingActivity.java
com.asp.radiorake.AlarmHelper.java
com.asp.radiorake.CallReceiver.java
com.asp.radiorake.ConfirmDetailsActivity.java
com.asp.radiorake.DatabaseHelper.java
com.asp.radiorake.DatePickerFragment.java
com.asp.radiorake.LastPlayedFile.java
com.asp.radiorake.ListScheduledRecordingsActivity.java
com.asp.radiorake.NotificationHelper.java
com.asp.radiorake.PlayerService.java
com.asp.radiorake.PlayingFile.java
com.asp.radiorake.RadioActivity.java
com.asp.radiorake.RadioApplication.java
com.asp.radiorake.RadioDetails.java
com.asp.radiorake.RebootBroadcastReceiver.java
com.asp.radiorake.RecordingsActivity.java
com.asp.radiorake.RecordioBaseActivity.java
com.asp.radiorake.RemoteControlReceiver.java
com.asp.radiorake.ScheduledRecordingsCursorAdaptor.java
com.asp.radiorake.TimePickerFragment.java
com.asp.radiorake.filehandling.FileHandler.java
com.asp.radiorake.filehandling.M3uHandler.java
com.asp.radiorake.filehandling.PlsHandler.java
com.asp.radiorake.recording.RecorderService.java
com.asp.radiorake.recording.RecordingBroadcastReceiver.java
com.asp.radiorake.utils.DateUtils.java
com.asp.radiorake.utils.StringUtils.java