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 getWeekNumberFromSeconds(long secs) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(secs * 1000L);/*w ww .j a v a 2 s . c om*/ SimpleDateFormat format1 = new SimpleDateFormat("ww"); return format1.format(c.getTime()); }
From source file:Main.java
public static Date getLastWeekOfYear(Date date) { // Set time//w w w . j av a 2 s. c o m Calendar calendar = Calendar.getInstance(); calendar.setTime(date); // Go to last week calendar.add(Calendar.WEEK_OF_YEAR, -1); return calendar.getTime(); }
From source file:Main.java
public static String getCurrentDateForPDF() { String str = null;/*from w w w.j a v a2s . c o m*/ String outputPattern = "dd.MM.yyyy"; 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 weekDayOfWeek(Date startWeekDate, int day) { Calendar calendar = Calendar.getInstance(Locale.GERMANY); calendar.setTime(startWeekDate);//from w w w. j a v a 2 s. c o m calendar.add(Calendar.DAY_OF_YEAR, day); return calendar.getTime(); }
From source file:Main.java
public static String CurrentDateToDisplay() { String str = null;//from w w w.ja v a2 s . co m String outputPattern = "dd.MM.yyyy hh:mm a"; 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 substractMinutes(Date date, int minutes) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);//from www. j ava 2 s . co m calendar.add(Calendar.MINUTE, -minutes); Date result = calendar.getTime(); return result; }
From source file:Main.java
public static String getYearFromDate(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date);/*from w ww. j av a 2 s. co m*/ SimpleDateFormat formatter = new SimpleDateFormat("yyyy"); String s = formatter.format(c.getTime()); return s; }
From source file:Main.java
public static String getMonthNameFromSeconds(long secs) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(secs * 1000L);/* w w w . j a va2s . c o m*/ SimpleDateFormat format1 = new SimpleDateFormat("MMMM"); return format1.format(c.getTime()); }
From source file:Main.java
public static String getFormatDateAdd(Date date, int amount, String format) { Calendar cal = new GregorianCalendar(); cal.setTime(date);//from w ww . j ava2 s.co m cal.add(GregorianCalendar.DATE, amount); return getFormatDateTime(cal.getTime(), format); }
From source file:Main.java
public static String getMonthLastDay() { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH)); return dateFormat.format(calendar.getTime()); }