Example usage for java.util Calendar getTime

List of usage examples for java.util Calendar getTime

Introduction

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

Prototype

public final Date getTime() 

Source Link

Document

Returns a Date object representing this Calendar's time value (millisecond offset from the Epoch").

Usage

From source file:ezbake.services.provenance.graph.Utils.java

public static Date convertDateTime2Date(final ezbake.base.thrift.DateTime dateTime) {
    Calendar calendar = DateTimeConverter.transformDateTime(dateTime);
    return calendar.getTime();
}

From source file:Main.java

public static String getDate(long time) {
    try {/*from   w  w w.j  ava 2  s.  co m*/
        Calendar c = Calendar.getInstance();
        c.setTimeInMillis(time);
        return format.format(c.getTime());
    } catch (Exception e) {
        e.printStackTrace();
    }
    return "";
}

From source file:Main.java

/**
 * Adds to a date returning a new object.
 * The original date object is unchanged.
 *
 * @param date  the date, not null/*from  w w  w . j a  v  a  2s  . c om*/
 * @param calendarField  the calendar field to add to
 * @param amount  the amount to add, may be negative
 * @return the new date object with the amount added
 * @throws IllegalArgumentException if the date is null
 */
private static Date add(Date date, int calendarField, int amount) {
    if (date == null) {
        throw new IllegalArgumentException("The date must not be null");
    }
    Calendar c = Calendar.getInstance();
    c.setTime(date);
    c.add(calendarField, amount);
    return c.getTime();
}

From source file:Main.java

public static String toYYYYMMDDHHMMSS(Calendar source) {
    if (source != null) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
        return format.format(source.getTime());
    }/*from w w w . j av a2s  . com*/
    return null;
}

From source file:Main.java

public static String getFormattedDate(String date) {
    java.util.Calendar calendar = getCalendarFromStringDate(date);
    SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy',' h:mm");

    return format.format(calendar.getTime());
}

From source file:Main.java

public static String parseTime(String date) {
    Calendar c = Calendar.getInstance();
    c.setTimeInMillis(Long.parseLong(date));
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    return sdf.format(c.getTime());

}

From source file:Main.java

public static String getDeadTime(int unit, int amount) {
    Calendar nowTime = Calendar.getInstance();
    nowTime.add(unit, amount);//w  ww .ja va  2 s.c  om

    nowTime.add(Calendar.HOUR_OF_DAY, 8);
    return new SimpleDateFormat("yyyyMMddHHmmssSSS").format(nowTime.getTime());
}

From source file:Main.java

public static String getCalendarString(Calendar dateTime) {
    // example: 24 May 2014, 10:13 PM
    SimpleDateFormat format = new SimpleDateFormat("d MMMM yyyy, h:mm a", Locale.getDefault());
    return format.format(dateTime.getTime());
}

From source file:Main.java

public static String getCurrentDate() {
    Calendar cal = Calendar.getInstance(Locale.ENGLISH);
    SimpleDateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String txtcurrentDate = dateFormat1.format(cal.getTime());
    return txtcurrentDate;
}

From source file:com.microsoft.live.TestUtils.java

public static LiveConnectSession newMockLiveConnectSession() {
    LiveAuthClient authClient = TestUtils.newMockLiveAuthClient();
    LiveConnectSession session = new LiveConnectSession(authClient);
    session.setAccessToken("access_token");
    session.setAuthenticationToken("authentication_token");

    Calendar calendar = Calendar.getInstance();
    calendar.add(Calendar.SECOND, 3600);
    session.setExpiresIn(calendar.getTime());

    String[] scopes = { "scope" };
    session.setScopes(Arrays.asList(scopes));
    session.setRefreshToken("refresh_token");
    session.setTokenType("token_type");

    return session;
}