List of usage examples for java.util Date Date
public Date()
From source file:Main.java
public static void main(String[] args) { SimpleDateFormat sdfDate = new SimpleDateFormat("dd/MM/yyyy"); Date now = new Date(); String strDate = sdfDate.format(now); System.out.println("Date: " + strDate); }
From source file:MainClass.java
public static void main(String args[]) { Date currentDate = new Date(); System.out.println(currentDate); // Get date object initialized to the epoch (Jan 1 1970) Date epoch = new Date(0); System.out.println(epoch);//from w w w . j a va 2 s .com }
From source file:Main.java
public static void main(String[] av) { Date d1 = new GregorianCalendar(2000, 11, 31, 23, 59).getTime(); Date today = new Date(); long diff = today.getTime() - d1.getTime(); System.out.println(//from w w w . j a v a 2s . com "The 21st century (up to " + today + ") is " + (diff / (1000 * 60 * 60 * 24)) + " days old."); }
From source file:Main.java
public static void main(String[] args) { TimeZone tz = TimeZone.getTimeZone("America/New_York"); System.out.println(tz.inDaylightTime(new Date())); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Locale locale = Locale.ITALIAN; Date date = new Date(); String s = DateFormat.getTimeInstance(DateFormat.SHORT, locale).format(date); System.out.println(s);//from w ww. j a va2 s . c o m }
From source file:Main.java
public static void main(String args[]) { SimpleDateFormat df = new SimpleDateFormat("dd/MM/yy"); java.util.Date date = new Date(); df.applyPattern("EEE"); String day = df.format(date); if (day.compareTo("Sat") == 0 || day.compareTo("Sun") == 0) { System.out.println(day + ": Weekend"); } else {//from www . j a v a2 s.co m System.out.println(day + ": Weekday"); } }
From source file:Main.java
public static void main(String[] args) { Date today = new Date(); Calendar calendar = Calendar.getInstance(); calendar.setTime(today);/*from ww w .ja va 2 s . c o m*/ calendar.add(Calendar.MONTH, 1); calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.add(Calendar.DATE, -1); Date lastDayOfMonth = calendar.getTime(); DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); System.out.println("Today : " + sdf.format(today)); System.out.println("Last Day of Month: " + sdf.format(lastDayOfMonth)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Locale locale = Locale.ITALIAN; Date date = new Date(); DateFormat df = DateFormat.getTimeInstance(DateFormat.MEDIUM, locale); String s = df.format(date);/*from w w w.ja va2 s .c o m*/ System.out.println(s); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Locale locale = Locale.ITALIAN; Date date = new Date(); DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT, locale); String s = df.format(date);// w ww . j a v a 2 s .co m System.out.println(s); }
From source file:Main.java
public static void main(String args[]) { TimeZone timezoneone = TimeZone.getDefault(); // create date object Date date = new Date(); // checking day light System.out.println("In daylight time:" + timezoneone.inDaylightTime(date)); }