Example usage for android.text.format Time setToNow

List of usage examples for android.text.format Time setToNow

Introduction

In this page you can find the example usage for android.text.format Time setToNow.

Prototype

public void setToNow() 

Source Link

Document

Sets the time of the given Time object to the current time.

Usage

From source file:Main.java

public static long getCurrentTime() {
    Time time = new Time();
    time.setToNow();
    return (time.hour * 60 * 60 + time.minute * 60) * 1000;
}

From source file:Main.java

public static String getTimeStamp() {
    Time now = new Time();
    now.setToNow();
    String sTime = now.format("%Y_%m_%d_%H_%M_%S");
    return sTime;
}

From source file:Main.java

static long getTimestamp() {
    Time time = new Time();
    time.setToNow();
    return time.toMillis(false);
}

From source file:Main.java

public static int getJulianDay() {
    Time dayTime = new Time();
    dayTime.setToNow();
    return Time.getJulianDay(System.currentTimeMillis(), dayTime.gmtoff);
}

From source file:Main.java

/********** Time **********/

public static long currentTimeInMillis() {
    Time time = new Time();
    time.setToNow();
    return time.toMillis(false);
}

From source file:Main.java

public static String now() {
    Time localTime = new Time();
    localTime.setToNow();
    return localTime.format("%Y%m%d%H%M%S");
}

From source file:Main.java

public static String getFormattedDate(Context context, long dateInMillis) {
    Time time = new Time();
    time.setToNow();
    SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM dd, yyyy");
    String dateString = dateFormat.format(dateInMillis);
    return dateString;
}

From source file:Main.java

public static String GetCurrentFormatTime(String format) {
    Time time = new Time();
    time.setToNow();
    return GetCurrentFormatTime(time.toMillis(false), format);
}

From source file:Main.java

public static String getNowTime() {
    Time time = new Time();
    time.setToNow();
    int year = time.year;
    int month = time.month + 1;
    int day = time.monthDay;
    int minute = time.minute;
    int hour = time.hour;
    int sec = time.second;
    return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + sec;
}

From source file:Main.java

public static String getSysDate() {

    Time t = new Time();
    t.setToNow();
    int year = t.year;
    int month = t.month + 1;
    int day = t.monthDay;

    int hour = t.hour; // 0-23
    int minute = t.minute;
    int second = t.second;

    return String.format("%04d%02d%02d%02d%02d%02d", year, month, day, hour, minute, second,
            Locale.getDefault());
}