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;
import java.util.*;

public class Main {
    public static String getToday() {
        Calendar now = Calendar.getInstance();
        return fd(new java.util.Date(now.getTime().getTime()));
    }//from  w  w w.j  a va  2  s. c  o  m

    public static String fd(java.util.Date d) {
        java.util.Calendar calendar = java.util.Calendar.getInstance();
        calendar.setTime(d);
        return (lz(calendar.get(Calendar.DATE), 2) + "/" + lz(calendar.get(Calendar.MONTH) + 1, 2) + "/"
                + calendar.get(Calendar.YEAR));
    }

    public static String lz(int src, int len) {
        return (lz(src + "", len));
    }

    public static String lz(String src, int len) {
        for (int i = 0; src.length() < len; i++) {
            src = "0" + src;
        }
        return (src);
    }
}

Related

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