Example usage for java.util Calendar setTimeInMillis

List of usage examples for java.util Calendar setTimeInMillis

Introduction

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

Prototype

public void setTimeInMillis(long millis) 

Source Link

Document

Sets this Calendar's current time from the given long value.

Usage

From source file:Main.java

public static void setDateTime(long timeStamp, Calendar currentCalender, int i) {
    currentCalender.setTimeInMillis(timeStamp);
    currentCalender.set(Calendar.DATE, 1);
    currentCalender.set(Calendar.HOUR_OF_DAY, 0);
    currentCalender.set(Calendar.MINUTE, 0);
    currentCalender.set(Calendar.SECOND, 0);
    currentCalender.set(Calendar.MILLISECOND, 0);
    currentCalender.add(Calendar.DATE, i);
}

From source file:Main.java

public static String GetFormatDateYMStrByMillseconds(long milliseconds) {
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(milliseconds);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
    return sdf.format(cal.getTime());
}

From source file:Main.java

public static String msToDate(String ms) {
    long miliseconds = Long.parseLong(ms);
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yy hh:mm aaa");

    Calendar c = Calendar.getInstance();
    c.setTimeInMillis(miliseconds);
    return sdf.format(c.getTime());
}

From source file:Main.java

public static String GetPostCommentTime(long milliseconds) {
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(milliseconds);
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd HH:mm");
    return sdf.format(cal.getTime());
}

From source file:Main.java

public static int[] formatTimeToArray(long time) {
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(time);
    int hour = cal.get(Calendar.HOUR_OF_DAY);
    int minute = cal.get(Calendar.MINUTE);
    return new int[] { hour, minute };
}

From source file:Main.java

public static String CreateTimeFormat_second(long time) {
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(time);
    return formatter.format(cal.getTime());
}

From source file:Main.java

public static String GetPostingTime(long milliseconds) {
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(milliseconds);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm");
    return sdf.format(cal.getTime());
}

From source file:Main.java

public static long getTodayMills() {
    Calendar c = Calendar.getInstance();
    c.setTimeInMillis(System.currentTimeMillis());
    c.set(Calendar.HOUR_OF_DAY, 0);
    c.set(Calendar.MINUTE, 0);// w  w w  . j  a v a  2  s  .  co m
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MILLISECOND, 0);
    return c.getTimeInMillis();
}

From source file:Main.java

public static Calendar createCalendar(long time) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(time);
    return calendar;
}

From source file:Main.java

public static Calendar calendarLocal_FromMilliseconds(long msUTC) {
    Calendar c = Calendar.getInstance();
    c.setTimeInMillis(msUTC);
    return c;/*from   ww  w . j a v a2 s.c om*/
}