how to convert date to yy-mm-dd in scala

Misha

I want to convert the date from dd-mm-yy to yy-mm-dd in scala, but I am having issues to make it happen

val format = new java.text.SimpleDateFormat("dd-mm-yyyy")
format.format(new java.util.Date())
output:
res0: String = 06-07-2018

but if I want to change the format to yy-mm-dd:

val format = new java.text.SimpleDateFormat("yy-mm-dd")
format.format(new java.util.Date())
output:
res2: String = 18-41-06

what did I do wrong? why the mm comes out as 41?

Ramesh Maharjan

The correct format is

val format = new java.text.SimpleDateFormat("yyyy-MM-dd")

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to convert date format "dd/mm/yy" to "yy/mm/dd" for mysql database inserting?

How to convert date dd/mm/YY to mm-dd-YY format in PHP

How to convert the given date to dd-mm-yy format in javascript?

How to change/convert input date format from MM dd yy to yyyy-mm-dd on submit

How To Convert String ' dd/mm/yy hh:MM:ss ' to Date in javascript?

how to convert sql date formate unix time stamp to date format as dd mm yy format?

How to convert MM/YY to YYYY-MM-DD in MYSQL

Excel - Convert date from yymmdd to dd/mm/yy

The simplest way to convert a long date format to YY/MM/DD HTML

Excel - convert part of filename to mm/dd/yy date

How do I convert a DateTime variable to return date in the 'mm/dd/yy' format

Date format dd/mm/yy

Regular expression convert Date format from dd-mon-yy to dd/MM/yy

GoogleFinace convert dd/mm/yy to yy,mm,dd format

Method to reorganize messed mm/dd/yy and dd/mm/yy date

Convert date with format dd.mm.yy to yyyy-mm-dd in python

want to convert string mm/dd/yy to date yyyy/mm/dd format in Sybase

Convert Timestamp string (dd MMM yyyy HH:mm:ss) to Date (DD/MM/YY) in Google Sheets

VB.NET: Convert a date dd/mm/yy to dd/mm/yyyy

Javascript convert date format from "dd/mm/yy" to "mm/dd/yyyy"

How to convert excel dates dd/mm/yy into number format such as 01011994

How to insert a date in the format dd-mm-yy in MySQL?

JavaScript how to get tomorrows date in format dd-mm-yy

How to generate every single date MM/DD/YY in python

How to get the previous date ( dd/mm/yy) in flutter

How to change date format (MM/DD/YY) to (YYYY-MM-DD) in date picker

How to change Date Format dd-mm-yy to yyyy-mm-dd

JQuery Datepicker date format - How to change from dd/mm/yyyy to dd/mm/yy?

How to convert date in format mm/yy from character to date class?