Example usage for android.text.format Time Time

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

Introduction

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

Prototype

public Time() 

Source Link

Document

Construct a Time object in the default timezone.

Usage

From source file:Main.java

public static String now() {
    Time localTime = new Time();
    localTime.setToNow();/*from  w  w  w  . j  a  va 2  s .  c  o  m*/
    return localTime.format("%Y%m%d%H%M%S");
}

From source file:Main.java

public static String getTimeStamp() {
    Time now = new Time();
    now.setToNow();// www . j av  a2  s. c om
    String sTime = now.format("%Y_%m_%d_%H_%M_%S");
    return sTime;
}

From source file:Main.java

public static long getCurrentTime() {
    Time time = new Time();
    time.setToNow();//  ww  w  .  j a  va2 s.c  om
    return (time.hour * 60 * 60 + time.minute * 60) * 1000;
}

From source file:Main.java

public static int getJulianDay() {
    Time dayTime = new Time();
    dayTime.setToNow();//w w w  .  j a  v a2 s. c om
    return Time.getJulianDay(System.currentTimeMillis(), dayTime.gmtoff);
}

From source file:Main.java

public static String getNowTime() {
    Time time = new Time();
    time.setToNow();/*w  w w . j  a  va 2 s.  c om*/
    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 boolean isThisYear(long when) {
    Time time = new Time();
    time.set(when);/* w w w.j  a  v a  2  s.  c om*/

    int thenYear = time.year;
    //      int thenMonth = time.month;
    int thenMonthDay = time.monthDay;

    time.set(System.currentTimeMillis());
    return (thenYear == time.year) && (thenMonthDay != time.monthDay);
}

From source file:Main.java

private static boolean isTomorrow(long when) {
    Time time = new Time();
    time.set(when);/*from w  w  w. jav a  2s  . co  m*/

    int thenYear = time.year;
    int thenMonth = time.month;
    int thenMonthDay = time.monthDay;
    thenMonthDay--;

    time.setToNow();
    return (thenYear == time.year) && (thenMonth == time.month) && (thenMonthDay == time.monthDay);
}

From source file:Main.java

public static long getNumberOfDaysPassed(long date1, long date2) {
    Time sThenTime = new Time();
    sThenTime.set(date1);//from w ww  .j  a  v  a  2 s  . c  o m
    int day1 = Time.getJulianDay(date1, sThenTime.gmtoff);
    sThenTime.set(date2);
    int day2 = Time.getJulianDay(date2, sThenTime.gmtoff);
    return Math.abs(day2 - day1);
}

From source file:Main.java

public static String getSysDate() {

    Time t = new Time();
    t.setToNow();//ww w. j  a  v a 2  s  . co m
    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());
}

From source file:Main.java

public static String getFormat3339ByDate(Date date, boolean isallDay) {
    Time time = new Time();
    time.set(date.getTime());/*  ww  w  .j  ava 2s .c o  m*/
    return time.format3339(isallDay);
}