Groovy - simple date reformatting [duplicate]
This question already has an answer here:
Java SimpleDateFormat always returning January for Month
3 answers
I am using the below code to convert "Oct 09, 2018"
to "20181009"
.
import java.text.SimpleDateFormat
import java.util.Date
def olddate = "Oct 09, 2018"
def date = Date.parse( "MMM DD, yyyy", olddate )
def newDate = new SimpleDateFormat("yyyyMMdd").format(date)
The problem is that I get the below output:
20180109
Irrespective of what date I convert the code returns the month as January (01)
java groovy
marked as duplicate by doelleri, pushkin, cfrick, Mark Rotteveel
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 16 at 14:53
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Java SimpleDateFormat always returning January for Month
3 answers
I am using the below code to convert "Oct 09, 2018"
to "20181009"
.
import java.text.SimpleDateFormat
import java.util.Date
def olddate = "Oct 09, 2018"
def date = Date.parse( "MMM DD, yyyy", olddate )
def newDate = new SimpleDateFormat("yyyyMMdd").format(date)
The problem is that I get the below output:
20180109
Irrespective of what date I convert the code returns the month as January (01)
java groovy
marked as duplicate by doelleri, pushkin, cfrick, Mark Rotteveel
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 16 at 14:53
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Java SimpleDateFormat always returning January for Month
3 answers
I am using the below code to convert "Oct 09, 2018"
to "20181009"
.
import java.text.SimpleDateFormat
import java.util.Date
def olddate = "Oct 09, 2018"
def date = Date.parse( "MMM DD, yyyy", olddate )
def newDate = new SimpleDateFormat("yyyyMMdd").format(date)
The problem is that I get the below output:
20180109
Irrespective of what date I convert the code returns the month as January (01)
java groovy
This question already has an answer here:
Java SimpleDateFormat always returning January for Month
3 answers
I am using the below code to convert "Oct 09, 2018"
to "20181009"
.
import java.text.SimpleDateFormat
import java.util.Date
def olddate = "Oct 09, 2018"
def date = Date.parse( "MMM DD, yyyy", olddate )
def newDate = new SimpleDateFormat("yyyyMMdd").format(date)
The problem is that I get the below output:
20180109
Irrespective of what date I convert the code returns the month as January (01)
This question already has an answer here:
Java SimpleDateFormat always returning January for Month
3 answers
java groovy
java groovy
edited Nov 15 at 23:23
pushkin
3,939112651
3,939112651
asked Nov 15 at 22:49
ASHAW401
32
32
marked as duplicate by doelleri, pushkin, cfrick, Mark Rotteveel
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 16 at 14:53
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by doelleri, pushkin, cfrick, Mark Rotteveel
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 16 at 14:53
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
"MMM DD, yyyy
is wrong. Change to MMM dd, yyyy
; D
means "day of year", while d
is "day of month". See e.g. https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
"MMM DD, yyyy
is wrong. Change to MMM dd, yyyy
; D
means "day of year", while d
is "day of month". See e.g. https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
add a comment |
"MMM DD, yyyy
is wrong. Change to MMM dd, yyyy
; D
means "day of year", while d
is "day of month". See e.g. https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
add a comment |
"MMM DD, yyyy
is wrong. Change to MMM dd, yyyy
; D
means "day of year", while d
is "day of month". See e.g. https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
"MMM DD, yyyy
is wrong. Change to MMM dd, yyyy
; D
means "day of year", while d
is "day of month". See e.g. https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
edited Nov 16 at 12:09
cfrick
18.1k13452
18.1k13452
answered Nov 16 at 7:44
Evgeny Smirnov
1,9681516
1,9681516
add a comment |
add a comment |