List of usage examples for java.util GregorianCalendar getTime
public final Date getTime()
Date
object representing this Calendar
's time value (millisecond offset from the Epoch"). From source file:com.tdclighthouse.prototype.utils.TdcUtils.java
public static String getExpiresDate(int hours) { GregorianCalendar calendar = new GregorianCalendar(); calendar.add(Calendar.HOUR, hours); Date date = calendar.getTime(); return dateToRFC1123(date); }
From source file:org.apache.ranger.common.DateUtil.java
public static Date getLocalDateForUTCDate(Date date) { Calendar local = Calendar.getInstance(); int offset = local.getTimeZone().getOffset(local.getTimeInMillis()); GregorianCalendar utc = new GregorianCalendar(); utc.setTimeInMillis(date.getTime()); utc.add(Calendar.MILLISECOND, offset); return utc.getTime(); }
From source file:org.apache.ranger.common.DateUtil.java
public static Date getUTCDate(long epoh) { if (epoh == 0) { return null; }/* ww w .ja va2s . c o m*/ try { Calendar local = Calendar.getInstance(); int offset = local.getTimeZone().getOffset(epoh); GregorianCalendar utc = new GregorianCalendar(gmtTimeZone); utc.setTimeInMillis(epoh); utc.add(Calendar.MILLISECOND, -offset); return utc.getTime(); } catch (Exception ex) { return null; } }
From source file:org.bimserver.plugins.web.AbstractWebModulePlugin.java
private static Date makeExpiresDate() { GregorianCalendar gregorianCalendar = new GregorianCalendar(); gregorianCalendar.add(Calendar.DAY_OF_YEAR, 120); return gregorianCalendar.getTime(); }
From source file:DateUtility.java
/** * This utility returns the first millsecond * of the month, and year, and timezone supplied as arguments. * * @param int month/* ww w .j ava2 s. com*/ * @param int year * @param TimeZone tz * @return long */ static public long getFirstMilliOfMonth(int year, int month, TimeZone tz) { GregorianCalendar cal = new GregorianCalendar(year, (month - 1), 1); cal.setTimeZone(tz); return cal.getTime().getTime(); }
From source file:org.springframework.cloud.netflix.rx.ObservableSseEmitterTest.java
private static Date getDate(int year, int month, int day) { GregorianCalendar calendar = new GregorianCalendar(year, month, day, 12, 0, 0); calendar.setTimeZone(TimeZone.getTimeZone("UTC")); return calendar.getTime(); }
From source file:org.apache.ranger.common.DateUtil.java
public static Date getUTCDate() { try {/* www. ja v a 2 s.co m*/ Calendar local = Calendar.getInstance(); int offset = local.getTimeZone().getOffset(local.getTimeInMillis()); GregorianCalendar utc = new GregorianCalendar(gmtTimeZone); utc.setTimeInMillis(local.getTimeInMillis()); utc.add(Calendar.MILLISECOND, -offset); return utc.getTime(); } catch (Exception ex) { return null; } }
From source file:Main.java
public static String timeFormat(Date date, String format) { GregorianCalendar gc = new GregorianCalendar(); gc.setTime(date);//from w w w . j a va 2 s.com java.text.SimpleDateFormat fm = null; if (format != null) { fm = new java.text.SimpleDateFormat(format); } else { fm = new java.text.SimpleDateFormat(DEFAULT_FORMAT); } return fm.format(gc.getTime()); }
From source file:com.esofthead.mycollab.core.utils.DateTimeUtils.java
public static Date getCurrentDateWithoutMS() { GregorianCalendar calendar = new GregorianCalendar(); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MINUTE, 0); return calendar.getTime(); }
From source file:Main.java
public static String timeFormat(long date, String format) { GregorianCalendar gc = new GregorianCalendar(); gc.setTime(new Date(date)); java.text.SimpleDateFormat fm = null; if (format != null) { fm = new java.text.SimpleDateFormat(format); } else {/*from ww w. j a va 2 s. c om*/ fm = new java.text.SimpleDateFormat(DEFAULT_FORMAT); } return fm.format(gc.getTime()); }