Example usage for java.util Date Date

List of usage examples for java.util Date Date

Introduction

In this page you can find the example usage for java.util Date Date.

Prototype

public Date() 

Source Link

Document

Allocates a Date object and initializes it so that it represents the time at which it was allocated, measured to the nearest millisecond.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {

    Format formatter = new SimpleDateFormat("HH.mm.ss");
    String s = formatter.format(new Date());
    System.out.println(s);/* w  w  w.j av  a 2 s  .c  om*/
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    Format formatter = new SimpleDateFormat("dd-MMM-yy");
    String s = formatter.format(new Date());
    System.out.println(s);//w  w  w  .j av a 2 s. c o  m
}

From source file:Unbuffered.java

public static void main(String args[]) {
    Reader reader;// ww w  .  j a v  a2s . c o  m
    int ch;
    System.out.println("Start! " + new Date());
    try {
        reader = new FileReader(args[0]);
        while ((ch = reader.read()) != -1) {
            // read entire file
        }
    } catch (IOException io) {
        System.err.println(io);
        System.exit(-1);
    }
    System.out.println("Stop! " + new Date());
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    SimpleDateFormat formatter = new SimpleDateFormat();

    String date = formatter.format(new Date());
    System.out.println("date = " + date);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    SimpleDateFormat formatter = new SimpleDateFormat();

    String date = formatter.format(new Date());
    System.out.println(formatter.get2DigitYearStart());
    System.out.println("date = " + date);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Format formatter = new SimpleDateFormat("EEE, dd MMM yyyy");
    String today = formatter.format(new Date());
    System.out.println("Today : " + today);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Format formatter = new SimpleDateFormat("EEE, dd/MM/yyyy");
    String today = formatter.format(new Date());
    System.out.println("Today : " + today);

}

From source file:Main.java

public static void main(String[] args) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(new Date());

    calendar.set(Calendar.DAY_OF_MONTH, 1);
    // day of week for first date of month
    int weekOfFirstDate = calendar.get(Calendar.WEEK_OF_YEAR);

    int lastDateOfMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
    calendar.set(Calendar.DAY_OF_MONTH, lastDateOfMonth);
    // day of week for last date of month

    int weekOfLastDate = calendar.get(Calendar.WEEK_OF_YEAR);

    calendar.roll(Calendar.MONTH, false);
    int lastDateOfPrevMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);

    int weeksToDisplay = weekOfLastDate - weekOfFirstDate + 1;
    int[] days = new int[weeksToDisplay * 7];

    int firstDayPosition = 3;

    // fill previous month
    int x = lastDateOfPrevMonth;
    for (int i = firstDayPosition - 1; i >= 0; i--) {
        days[i] = x--;/*w ww . j  a  v  a2  s . c  om*/
    }

    // fill current month
    for (int i = 1; i < lastDateOfMonth + 1; i++) {
        days[firstDayPosition - 1 + i] = i;
    }

    // fill next month
    int j = 1;
    for (int i = lastDateOfMonth + firstDayPosition; i < days.length; i++) {
        days[i] = j++;
    }

    for (int i = 0; i < days.length; i++) {
        if (i % 7 == 0) {
            System.out.println();
        }
        System.out.print(days[i] + "\t");
    }
}

From source file:Main.java

public static void main(String args[]) throws Exception {
    Properties p = new Properties();

    p.put("today", new Date().toString());
    p.put("user", "A");

    FileOutputStream out = new FileOutputStream("user.props");
    p.storeToXML(out, "updated");

    FileInputStream in = new FileInputStream("user.props");

    p.loadFromXML(in);//  www.  j  a v  a 2 s  .  co  m
    p.list(System.out);
}

From source file:Main.java

public static void main(String[] args) {
    String helloHtml = "<html>" + "<head>" + "   <title>Hello World from Java</title>" + "<body>"
            + "Hello, today is: " + new Date() + "</body>" + "</html>";

    String title = StringUtils.substringBetween(helloHtml, "<title>", "</title>");
    String content = StringUtils.substringBetween(helloHtml, "<body>", "</body>");

    System.out.println("title = " + title);
    System.out.println("content = " + content);
}