Java Time Now getNowYMD()

Here you can find the source of getNowYMD()

Description

get Now YMD

License

Apache License

Declaration

public static String getNowYMD() 

Method Source Code

//package com.java2s;
/**//w ww.jav a2s . c  om
 * Tern Framework.
 * 
 * @author fancimage
 * @Copyright 2010 qiao_xf@163.com Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 */

import java.util.Date;
import java.text.SimpleDateFormat;

public class Main {
    public static String getNowYMD() {
        String str = now();
        return str.substring(0, 10);
    }

    public static String now() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String dt = sdf.format(new Date());
        return dt;
    }

    public static String now(String pattern) {
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        String dt = sdf.format(new Date());
        return dt;
    }
}

Related

  1. getNowTime(String format)
  2. getNowTime(String format, Locale loc)
  3. getNowTime(String formatStr)
  4. getNowWithLocal(boolean ifdatetime)
  5. getNowYearMonth()
  6. getSpecifiedDateTime_235959(Date curDate)
  7. getStrCurrentStrTime()
  8. getThaiCurrentTime()
  9. getTimeFromCurrent(long l)