Java Today getToday()

Here you can find the source of getToday()

Description

get Today

License

Open Source License

Declaration

public static String getToday() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;

public class Main {
    public static String getToday() {
        Calendar cl = Calendar.getInstance();
        String month = "";
        String day = "";
        String today = "";
        String today2 = "";
        int m = cl.get(Calendar.MONTH) + 1;
        if (m < 10) {
            month = "0" + String.valueOf(m);
        } else {//w w  w. j  av  a2  s.c om
            month = String.valueOf(m);
        }
        int d = cl.get(Calendar.DATE);
        if (d < 10) {
            day = "0" + String.valueOf(d);
        } else {
            day = String.valueOf(d);
        }
        today = cl.get(Calendar.YEAR) + month + day + cl.get(Calendar.HOUR_OF_DAY) + cl.get(Calendar.MINUTE)
                + cl.get(Calendar.SECOND);
        today2 = cl.get(Calendar.YEAR) + "-" + month + "-" + day + " " + cl.get(Calendar.HOUR_OF_DAY) + ":"
                + cl.get(Calendar.MINUTE) + ":" + cl.get(Calendar.SECOND);
        return today2;
    }
}

Related

  1. getStartOfToday()
  2. getStartOfToday()
  3. getStringToday()
  4. getTimeNumberToday()
  5. getToday()
  6. getToday()
  7. getToday()
  8. getToday()
  9. getToday()