Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What is the easiest way to get just the 2 last digits of the year?  RSS feed

 
John Landon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
What is the easiest way to get just the 2 last digits of the year?
I am doing:

but it gives me 4 digits. I want just the last 2.

or

How can I get something like "010208" for Jan 02 2008?

Thanks.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
John Landon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
:-) haha thanks that's the obvious way. I thought about something with year formating.
 
Rob Spoor
Sheriff
Posts: 21090
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out java.text.SimpleDateFormat. You can let it do the entire formatting (using cal.getTime()).
 
Lakshman lax
Greenhorn
Posts: 4
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This can do in Java 8.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!