List of usage examples for java.util Calendar getTime
public final Date getTime()
Date
object representing this Calendar
's time value (millisecond offset from the Epoch"). From source file:Main.java
public static String formatDate(Calendar calendar) { String format = "yyyy-MM-dd HH:mm:ss"; SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US); return sdf.format(calendar.getTime()); }
From source file:Main.java
public static Date getTime(int year, int month, int day, int hour, int minute) { Calendar date = Calendar.getInstance(); date.set(year, month, day, hour, minute, 0); date.set(Calendar.MILLISECOND, 0); return date.getTime(); }
From source file:com.fanniemae.ezpie.common.DateUtilities.java
public static String toPrettyString(Calendar value) { return (value == null) ? "" : toPrettyString(value.getTime()); }
From source file:Main.java
public static String DateToServerFormat() { String str = null;/*from ww w . java 2 s.c o m*/ String outputPattern = "yyyy-MM-dd"; try { Calendar c = Calendar.getInstance(); SimpleDateFormat outputFormat = new SimpleDateFormat(outputPattern); str = outputFormat.format(c.getTime()); } catch (Exception e) { e.printStackTrace(); } return str; }
From source file:Main.java
public static Date getDateAdd(Date date, int amount) { Calendar cal = new GregorianCalendar(); cal.setTime(date);//from w w w. j ava 2s. c o m cal.add(GregorianCalendar.DATE, amount); return cal.getTime(); }
From source file:Main.java
public static String firstDayOfMonth() { Calendar c = Calendar.getInstance(); c.set(Calendar.DAY_OF_MONTH, 1); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); return df.format(c.getTime()); }
From source file:Main.java
public static String getWeekDayFromSeconds(long secs) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(secs * 1000L);//from www. j a v a 2s . c o m SimpleDateFormat format1 = new SimpleDateFormat("E"); return format1.format(c.getTime()); }
From source file:io.github.seiferma.jameica.hibiscus.dkb.creditcard.util.DateUtils.java
public static Date getDateAgo(Unit unit, int amount) { Validate.inclusiveBetween(0, Integer.MAX_VALUE, amount); Calendar calendar = new GregorianCalendar(); calendar.add(unit.getCalendarField(), -amount); return calendar.getTime(); }
From source file:Main.java
public static long date2long(int hour, int minute, int second) { Calendar c = Calendar.getInstance(); c.set(Calendar.HOUR_OF_DAY, 18); c.set(Calendar.MINUTE, 0);// w w w . j av a 2 s . co m c.set(Calendar.SECOND, 0); Date d = c.getTime(); return d.getTime(); }
From source file:Main.java
/** * @param dateString/*w ww .j av a 2 s . c o m*/ * @return a java Date object that correspond to the dateString * Convert the dateString to a Date object */ public static Date getDateFromString(String dateString) { // The Irish Time: "Mon, 15 Apr 2013 06:55:14 +0000" // Guardian / BBC: Wed, 17 Apr 2013 12:57:50 GMT String[] elements = dateString.split("[:\\s+]"); int year = Integer.parseInt(elements[3]); int month = getMonth(elements[2].toLowerCase()); int date = Integer.parseInt(elements[1]); int hour = Integer.parseInt(elements[4]); int minute = Integer.parseInt(elements[5]); int second = Integer.parseInt(elements[6]); Calendar cal = Calendar.getInstance(); cal.set(year, month, date, hour, minute, second); return cal.getTime(); }