Example usage for java.util Calendar getTimeInMillis

List of usage examples for java.util Calendar getTimeInMillis

Introduction

In this page you can find the example usage for java.util Calendar getTimeInMillis.

Prototype

public long getTimeInMillis() 

Source Link

Document

Returns this Calendar's time value in milliseconds.

Usage

From source file:Main.java

public static final long getValidTime(TimePicker timePicker) {
    Calendar c = Calendar.getInstance();
    c.set(Calendar.HOUR_OF_DAY, timePicker.getCurrentHour().intValue());
    c.set(Calendar.MINUTE, timePicker.getCurrentMinute().intValue());

    return c.getTimeInMillis();
}

From source file:Main.java

public static String getTimeAndDate(long j) {
    try {//from   ww  w .  j  av a2s. c  o  m
        Calendar instance = Calendar.getInstance();
        TimeZone timeZone = TimeZone.getDefault();
        instance.setTimeInMillis(j);
        instance.add(14, timeZone.getOffset(instance.getTimeInMillis()));
        String format = new SimpleDateFormat(" dd, MMM yyyy").format(instance.getTime());
        Time time = new Time();
        time.set(j);
        return time.format("%H:%M") + format;
    } catch (Exception e) {
        return "";
    }
}

From source file:Main.java

public static long getDateMills(int year, int month, int day) {
    //Date d = new Date(year, month, day);
    // 1960 4 22//from w  w  w .  ja v a 2  s . c  om
    Calendar calendar = Calendar.getInstance(Locale.CHINA);
    calendar.set(year, month, day);
    TimeZone tz = TimeZone.getDefault();
    calendar.setTimeZone(tz);
    return calendar.getTimeInMillis();
}

From source file:Main.java

public static Calendar localize(Calendar calendar) {
    if (calendar == null) {
        return calendar;
    }// w  w  w .  j a  v a 2s.  c  om
    final Calendar localCalendar = Calendar.getInstance();
    localCalendar.setTimeInMillis(calendar.getTimeInMillis());
    return localCalendar;
}

From source file:Main.java

private static long getTodayZeroTime() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.SECOND, 0);//  www.  j  ava2s  .  c o  m
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTimeInMillis();
}

From source file:Main.java

public static long getDayStart() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.SECOND, 0);/*from   w  w w  . j a va  2 s . c o m*/
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTimeInMillis();
}

From source file:Main.java

public static long getTimesStart() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.SECOND, 0);//from   ww  w . java2 s. com
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTimeInMillis();
}

From source file:Main.java

public static long getTimesNextStart() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, 24);
    cal.set(Calendar.SECOND, 0);//from ww w . ja  v a  2 s  . co  m
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTimeInMillis();
}

From source file:Main.java

private static long getYesterdayZeroTime() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, -24);
    cal.set(Calendar.SECOND, 0);/*w w  w.  j  a  va2  s . c  om*/
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTimeInMillis();
}

From source file:Main.java

public static long getTimesmorning() {
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.HOUR_OF_DAY, 0);
    cal.set(Calendar.SECOND, 0);/*from  w ww.  j ava 2 s .co  m*/
    cal.set(Calendar.MINUTE, 0);
    cal.set(Calendar.MILLISECOND, 0);
    return cal.getTimeInMillis();
}