get current date in java in yyyy mm dd hh mm ss format

get current date in java in yyyy mm dd hh mm ss format

Hi,

I want to get the current date into string yyyy mm dd hh mm ss format. How to get current date in java in yyyy mm dd hh mm ss format in a Java program?

Thanks

View Answers

July 21, 2017 at 4:48 AM

Hi,

Here is the complete example of getting current date into yyyy-mm-dd hh:mm:ss format.

package net.roseindia;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
/*
 * Format current date into yyyy-mm-dd hh:mm:ss String
 * format
 */
public class FormatCurrentDate {
    public static void main(String[] args) {
        try {
            //Current date to yyyy-mm-dd hh:mm:ss
            Date currentDate = new Date();
            DateFormat df = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
            String strCurrentDate = df.format(currentDate);
            System.out.println("Date is " + strCurrentDate);
        } catch (Exception e) {
            System.out.println("Exception :" + e);
        }

    }
}

Thanks









Related Tutorials/Questions & Answers:
get current date in java in yyyy mm dd hh mm ss format
get current date in java in yyyy mm dd hh mm ss format  Hi, I want to get the current date into string yyyy mm dd hh mm ss format. How to get current date in java in yyyy mm dd hh mm ss format in a Java program? Thanks  
Java convert string to date from format yyyy-mm-dd hh mm ss
Java convert string to date from format yyyy-mm-dd hh mm ss  Hi, I have date in the string yyyy-mm-dd hh mm ss format. Now I will want this string... to convert string date in format yyyy-mm-dd hh mm ss to date object. We need
Advertisements
convert yyyy-mm-dd hh mm ss to date in sql
convert yyyy-mm-dd hh mm ss to date in sql  Hi, How to convert yyyy-mm-dd hh mm ss to date in sql? Thanks   Hi, You should use following code in SQL DATE_FORMAT(STR_TO_DATE(my_date, "%Y/%m/%d %H:%i:%s.%f"), "%Y-%m
c# current date in yyyy-MM-dd format
format. In c# how to get current date in yyyy-mm-dd format...c# current date in yyyy-MM-dd format  Hi, How to get the current...(dateString ); Above code will give date into 2021-01-21 format (yyyy-MM-dd). I
How to convert current date to dd mm yyyy format in Java?
How to convert current date to dd mm yyyy format in Java?  Hi, How to convert current date to dd mm yyyy format in Java? In my program I have to display the current date in the dd-mm-yyyy format to user on the website. How
How to convert current date to mm dd yyyy format in Java?
How to convert current date to mm dd yyyy format in Java?  Hi, How to convert current date to mm dd yyyy format in Java? Share me the program... for converting current date into MM-dd-yyyy format. Here is full code: package
How to format current date into yyyy-mm-dd in Java
How to format current date into yyyy-mm-dd in Java  Hi, I have requirement to format the date into yyyy-MM-dd format for inserting it into MySQL...-dd"); formats the date into yyyy-MM-dd format. the MM is used for getting
How to get today's date in java in mm/dd/yyyy format?
Today's Date in MM/dd/yyyy format in Java - How to get today's date... examples of getting the current date in Java in MM/dd/yyyy format. Here MM... and then format it into MM/dd/yyyy format. Java comes with rich date API which can
php date format yyyy-mm-dd
php date format yyyy-mm-dd  date format yyyy-mm-dd validation
How to convert date to string in Java in yyyy-mm-dd format
to String in yyyy-mm-dd format. How to convert date to string in Java in yyyy... it to yyyy-mm-dd String format. Here is Java example for converting String Date...How to convert date to string in Java in yyyy-mm-dd format  Hi, I
how to format date from yyyy-mm-dd to dd-mm-yyyy
how to format date from yyyy-mm-dd to dd-mm-yyyy  <!DOCTYPE html... to calculate the nos. of days between two dates, the date format is in "yyyy-mm-dd", so what i want is in "dd-mm-yyyy" format. So, how to change it? I would be much
How to convert string to date in java in yyyy-mm-dd format?
How to convert string to date in java in yyyy-mm-dd format?  Hi, I have a date in yyyy-mm-dd format. How to convert string to date in java in yyyy... java.util.Date; /* * Example of formatting date in Java * from yyyy-mm-dd formaat
validationrule for date as format yyyy-mm-dd in drools
validationrule for date as format yyyy-mm-dd in drools  Please give... format yyyy-mm-dd: How i write the validation rule for date as a format yyyy-mm-dd...("outofServiceStartDate", "stmpOutOfServiceStartDateInvalid", "Please use the format yyyy-mm-dd
How to calculate sum of HH:MM:SS Format?
How to calculate sum of HH:MM:SS Format?  how to calculate sum of HH:MM:SS? for example: 10:25:36+26:50:56 calculate sum of these values
yyyy-mm-dd validation in javascript
yyyy-mm-dd validation in javascript   My form return value like (2011-10-05)yyyy-mm-dd ... my End date greater than my start date.. How to do validation in javascript
calculate milliseconds to hh mm ss
calculate milliseconds to hh mm ss  how to calculate milliseconds to hh mm ss ? Actually i wanted to calculate week days and hours from milliseconds..?   var seconds = (mil / 1000) | 0; mil -= seconds * 1000; var
how to convert the entire column field of table to dd/mm/yyyy format in microsoft sql server?
how to convert the entire column field of table to dd/mm/yyyy format... is in encryted like 1263332444 of table to dd/mm/yyyy format in microsoft sql server? i... to change entire date of column
Mysql Date Expression
a format  'YYYY-MM-DD' and 'HH.MM.SS'. Timestamp columns are displayed...; select current_timestamp() as Date; Output...) Query:- The now ( ) Query is used to return the current date
Get current Date and Time
_TO_REPLACE_1 DateFormat dateformat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss...[]) { DateFormat dateformat = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss... SimpleDateFormat("yyyy/MM/dd hh:mm:ss"); Calendar cal = Calendar.getInstance
Date validation in JSP
numbers of validations are done: The date format should be : MM/DD/YYYY Month...){ alert("The date format should be : MM/DD/YYYY") return false... error message date format should be MM/DD/YYYY. ADS_TO_REPLACE_4 If user does
Java program to get current date
Java program to get current date now  .../MMM/dd HH:mm:ss format. Here is the full example code...;   new SimpleDateFormat("yyyy/MMM/dd HH:mm:ss"
Mysql Date Type
the 'emp_dob ' records in 'yyyy-mm-dd' format. select emp_dob from employee: The select query return the emp_dob  records in "yyyy-mm-dd" format...; Mysql Date Type is used to show the date in "yyyy-mm-dd" format.The
Java Date Format Example
MMM yyyy HH mm ss Z"); Date date = new Date(); String newDateString... SimpleDateFormat("E dd MMM yyyy HH mm ss Z"); String newDateString...("E dd MMM yy HH mm ss Z", Locale.FRENCH); A Simple Example is given belowADS
JDBC : Current Date
the current date and time as a value in 'YYYY-MM-DD HH:MM:SS' SYSDATE()  : It returns the current date and time as a value in 'YYYY-MM-DD HH:MM:SS..., CURRENT_DATE() functions  return the current date in format 'YYYY-MM-DD
how to get date format in string from date object containing real date in java
-yyyy HH:mm:ss"); String datetext4=sdf4.format(date...how to get date format in string from date object containing real date in java  i want to get data string format from date object where date object
how to get date format in string from date object containing real date in java
-yyyy HH:mm:ss"); String datetext4=sdf4.format(date...how to get date format in string from date object containing real date in java  i want to get data string format from date object where date object
JDBC: Get current Date and Time Example
in the format 'YYYY-MM-DD' You can get current date by writing ... of 'HH:MM:SS'. You can get current date by writing  - SELECT...JDBC: Get current Date and Time Example In this section, you will learn how
java program
","MM","dd","HH","k","mm","ss","SS","MM-dd-yyyy k:mm:ss.SS"}; for(int i=0...java program  write a java program to get current date and time in the following format: current year is:2007 current month is:12 current date is:23
java program 18
[]={"yyyy","MM","dd","HH","k","mm","ss","SS","MM-dd-yyyy k:mm:ss.SS"}; for(int...java program 18  write a java program to get current date and time in the following format: current year is:2007 current month is:12 current date
convert current date into date format
convert current date into date format  How to get current date and convert into date format in Java or PHP
java format date
java format date  Hi, How can I format the date in the following pattern? yyyy-MM-dd   import java.util.*; import java.text.*; class...-MM-dd"); String formattedDate=sdf.format(date
Simple date formatter example
the date object into the "yyyy-MM-dd HH:mm:ss" format. formatter = new SimpleDateFormat("yyyy-MM-dd"); formattedDate = formatter.format(todaysDate);ADS... SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss
Parameter month I Report - Java Beginners
. But Date format in database dd/mm/yyyy , my question how to get mm/yyyy from database... formatter = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z"); s... = new SimpleDateFormat("EEEE, dd MMMM yyyy HH:mm:ss zzzz"); s
Parsing date in Java
Parsing date in Java  How can i parse the date in Java in a simple format..?   SimpleDateFormat parserSDF=new SimpleDateFormat("EEE MMM d HH:mm:ss zzz yyyy
date format - Java Beginners
date format  How to convert yyyy-mm-dd to dd-mmm-yyyy  Hi friend, Code to convert yyyy-mm-dd to dd-mmm-yyyy : import java.util.Date...(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-mm-dd
How to get the current date in Java?
How to get the current date in Java?  Hi, I am new to Java... in Java? Thanks   Hi, Check the tutorial: Java program to get current date. Thanks   Hi, To get the current date and time in Java you can use
struts2.2.1 date Format example
_TO_REPLACE_25 <hr> <b>Date Format (EEEE MM/dd/yyyy hh:mm AM/PM):<...;b>Date Format (EEEE dd-MMM-yyyy hh:mm AM/PM) :</b><br/><br... Current Date : <s:date name="currentDate" format="yyyy-MM
Get Date and Time
;static final String date = "yyyy-MM-dd HH:mm:ss"... current date and time in the user given format. To do all this we have first...;How to get date and time in Java?":ADS_TO_REPLACE_1
Date format - Java Server Faces Questions
Date format  Hi All, I have field like Invoice Date is displaying a date like MMddyyyy HH:mm:ss format.i want to set format to MM//dd//yy. To set the format for the field, I believe you have to use the jsf
String to date with no format
date format can be (mm-dd-yyyy) if the 99th record also was 06-06-2006 the result should be date format can be (mm-dd-yyyy;dd-mm-yyyy) can sum1 please help me... into a date .. this is simple .. but i want to do it without knowing the date format
select date in desired format
select date in desired format  how to select date from the database in DD/MM/YYYY format, because if i am trying select data from the database i am getting value in yyyy/mm/dd and time format like below "2012-05-07 00:00:00.0
Simple Date Format Example
SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z"); s = formatter.format(date); System.out.println(s); formatter = new SimpleDateFormat("EEEE, dd MMMM yyyy HH... formatter = new SimpleDateFormat("MM/dd/yy"); s = formatter.format(date
Java Date format - Java Server Faces Questions
dates in format(DD/MM/YYYY) import java.util.Date; import... format SimpleDateFormat sdfSource = new SimpleDateFormat("dd/MM/yyyy...Java Date format  Code to calculate days between two dates in format
Struts 2 Date Format Examples
; <tr> <td>Date in (MM/dd/yyyy hh:mm AM/PM) Format:</td>...;tr> <td>Date in (dd-MMM-yyyy hh:mm AM/PM) Format:</td>...; <td>Date in (dd/MM/yyyy hh:mm) Format:</td> <td>
String to Date format
SimpleDateFormat("yyyy-MM-dd"); String formattedDate=sdf.format(date...("yyyy-MM-dd"); String formattedDate=sdf.format(date...String to Date format  My Date format is String Eg(Jan 20 2011
JDBC: Get current TimeStamp Example
in the following format - yyyy-mm-dd hh:mm:ss.[fff...] ADS_TO_REPLACE_1  ...JDBC: Get current TimeStamp Example In this tutorial, we are going to describe how to get current TIMESTAMP using JDBC API. Get current TimeStamp : CURRENT
Date prorblem
into string filed in java code. once the date is available in filed ( of type String ) in java code, then i have to convert it into yyyy-mm-dd hh-mm-ss. then i have...) SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); DATEADDED1
Java current date - How to get current date in Java
In this section, you will learn about displaying current date and time in Java
Iphone Show Current Date & Time
setDateFormat:@"yyyy-MM-dd HH:MM:SS"]; The output of the application... setDateFormat:@"yyyy-MM-dd HH:MM:SS"... it was: [formatter setDateFormat:@"yyyy-MM-dd"]; in date example
ask java - Date Calendar
(); SimpleDateFormat sdf; //sdf = new SimpleDateFormat("dd/MMM/yyyy hh:mm:ss aa"); sdf = new SimpleDateFormat("yyyy/MM/dd"); System.out.println("date... SimpleDateFormat sdfSource = new SimpleDateFormat("yyyy/MM/dd"); //parse

Ads