Java Year Format getTimeByYMD()

Here you can find the source of getTimeByYMD()

Description

get Time By YMD

License

Open Source License

Declaration

public static String getTimeByYMD() 

Method Source Code

//package com.java2s;
/**// w ww  .j  ava 2s.c  om
 * Copyright @ 2007, ST Electronics Info-comm Systems PTE. LTD All rights
 * reserved.
 *
 * This software is confidential and proprietary property of ST Electronics
 * Info-comm Systems PTE. LTD. The user shall not disclose the contents of this
 * software and shall only use it in accordance with the terms and conditions
 * stated in the contract or licence agreement with ST Electronics Info-comm
 * Systems PTE. LTD.
 *
 * @author Jerry
 * @version 1.0
 *
 */

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

public class Main {
    public static String getTimeByYMD() {
        Date date = new Date(System.currentTimeMillis());
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String dateStr = sdf.format(date);
        String[] dateArray = dateStr.split("-");
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < dateArray.length; i++) {
            sb.append(dateArray[i]);
        }
        return sb.toString();
    }
}

Related

  1. getFirstDate(String yearMonthStr, String yearMonthFormat, String dateFormat)
  2. getFormatToDateSimple(String yyyyMMdd)
  3. getStartAndEndWeekOfMonth(int year, int month, int week, String format)
  4. getStringFormatMMYYWithoutHyphens(Date aDate)
  5. getStringFormatYYYYMMddWithHyphens(Date aDate)
  6. getYear(SimpleDateFormat df, String dateStr)
  7. getYear(String date, String dateformat)
  8. getYear(String pFormattedDate)
  9. getYYMMDD()