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:Main.java

public static Date getDateFromLong(long time) {
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(time);// w  w  w  .  ja  v a  2 s.  c o m
    return cal.getTime();
}

From source file:com.metamug.mtg.s3.uploader.S3Uploader.java

public static String upload(InputStream inputStream, long fileSize, String URI) {
    String publicURL;/*from www. j av a 2s  .  c om*/
    //ClientConfiguration max retry
    ObjectMetadata objectMetaData = new ObjectMetadata();
    objectMetaData.setContentLength(fileSize);
    //        objectMetaData.setContentType(IMAGE_CONTENT_TYPE);
    objectMetaData.setCacheControl("public");
    Calendar c = Calendar.getInstance();
    c.setTime(c.getTime());
    c.add(Calendar.MONTH, 6);
    String sdf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss zzz").format(c.getTime());
    objectMetaData.setHeader("Expires", sdf);//Thu, 21 Mar 2042 08:16:32 GMT

    PutObjectResult por = s3Client
            .putObject(new PutObjectRequest(AWS_S3_BUCKET, URI, inputStream, objectMetaData)
                    .withCannedAcl(CannedAccessControlList.PublicRead));

    publicURL = "http://metamug.net/" + URI;
    return publicURL;
}

From source file:Main.java

public static Date getDate(int year, int month, int day) {
    Calendar c = Calendar.getInstance();
    c.set(year, month, day, 0, 0);/*  ww w. j a v  a 2  s  .c  om*/
    return c.getTime();
}

From source file:Main.java

public static Date getDateObj() {
    Calendar c = new GregorianCalendar();
    return c.getTime();
}

From source file:Main.java

public static Date getYesterdayDate() {
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DATE, -1);//from  w  ww  . ja  v a  2s.c  o m
    return cal.getTime();
}

From source file:Main.java

public static String calendar2String(Calendar calendar) {
    if (calendar != null) {
        return format1.format(calendar.getTime());
    } else {//  w  w  w  .  j a  va  2s  . c o m
        return "";
    }
}

From source file:Main.java

public static String calendar2SimpleString(Calendar calendar) {
    if (calendar != null) {
        return format2.format(calendar.getTime());
    } else {//from   w ww . j  a  v a 2 s.c  o  m
        return "";
    }
}

From source file:Main.java

public static String getCurrentDate() {
    Calendar c = Calendar.getInstance();
    System.out.println("Current time => " + c.getTime());

    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String formattedDate = df.format(c.getTime());

    return formattedDate;
}

From source file:Main.java

static Calendar toNearestWholeMinute(Calendar d) {
    Calendar c = new GregorianCalendar();
    c.setTime(d.getTime());

    if (c.get(Calendar.SECOND) >= 30)
        c.add(Calendar.MINUTE, 1);

    c.set(Calendar.SECOND, 0);/* w  ww.  j  a va 2 s.  c o  m*/

    return c;
}

From source file:Main.java

public static String getCurrentDateTime() {
    DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd HHmmss");
    Calendar cal = Calendar.getInstance();
    String currentDateTime = dateFormat.format(cal.getTime());
    return currentDateTime;
}