- 论坛徽章:
- 0
|
For my day
import java.util.Calendar;
public class MyDay {
public static void main(String args[]) {
Calendar cal = Calendar.getInstance();
long now = cal.getTimeInMillis();
cal.set(2007, 10, 1);
long one = cal.getTimeInMillis();
int dayNum = (int)((now - one) / (1000*60*60*24.0));
// binary format
String str = Integer.toBinaryString(dayNum);
// prefix with zeros
while (str.length()8) {
str = "0" + str;
}
System.out.println(dayNum);
System.out.println(str);
}
}
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/39889/showart_512418.html |
|