| |

VerySource

 Forgot password?
 Register
Search
Author: 890804zzz

Ask for help! Come check it out! The rookie problem Help us a lot! !! !!

[Copy link]

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-6-2 17:00:02
| Show all posts
java.util.Calendar c=java.util.Calendar.getInstance();
if(c.get(java.util.Calendar.DAY_OF_YEAR)<10){
     out.println(c.get(java.util.Calendar.YEAR)+"00"+c.get(java.util.Calendar.DAY_OF_YEAR));
     
    }
if(c.get(java.util.Calendar.DAY_OF_YEAR)>10&&c.get(java.util.Calendar.DAY_OF_YEAR)<100){
     out.println(c.get(java.util.Calendar.YEAR)+"0"+c.get(java.util.Calendar.DAY_OF_YEAR));
     
    }
if(c.get(java.util.Calendar.DAY_OF_YEAR)>100){
     out.println(c.get(java.util.Calendar.YEAR)+""+c.get(java.util.Calendar.DAY_OF_YEAR));
     
    }

solved
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-6-14 08:30:02
| Show all posts
java.util.Calendar c=java.util.Calendar.getInstance();
String s = "000";
String years = String.valueOf(c.get(java.util.Calendar.YEAR));
String days = String.valueOf(c.get(java.util.Calendar.DAY_OF_YEAR));
s = years.concat(s.substring(0,s.length()-days.length()).concat(days));
The
System.out.println(s);
Reply

Use magic Report

0

Threads

14

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-6-17 17:45:02
| Show all posts
java.util.Calendar c=java.util.Calendar.getInstance();
String a = "000"+c.get(java.util.Calendar.DAY_OF_YEAR);
a=a.substring(a.length()-3);
System.out.print(c.get(java.util.Calendar.YEAR)+a.substring(a.length()-3));
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list