java String.Format() ÈÕÆÚ¸ñʽÓ÷¨
ÔÎÄ´«ËÍÃÅ£ºhttp://solodu.javaeye.com/blog/454546
JDK1.5ÖУ¬StringÀàÐÂÔöÁËÒ»¸öºÜÓÐÓõľ²Ì¬·½·¨String.format():ÏÖÓÐÒ»¸öʱ¼ä'20090903'Ҫת»¯³ÉÖ¸¶¨Ê±¼äµÄjava.util.Date¸ñʽ
private Date getStartGregorianTime(String date) {
Date d_date = DateUtil.parseDate(date);
int year = new Integer(String.format("%tY", d_date));
int month = new Integer(String.format("%tm", d_date));
int day = new Integer(String.format("%td", d_date));
return new GregorianCalendar(year, month-1, day, 0, 0, 0).getTime();
}
private Date getEndGregorianTime(String date) {
Date d_date = DateUtil.parseDate(date);
int year = new Integer(String.format("%tY", d_date));
int month = new Integer(String.format("%tm", d_date));
int day = new Integer(String.format("%td", d_date));
return new GregorianCalendar(year, month-1, day, 23, 59, 59).getTime();
}
ÒÔÏÂΪString format()ÖвÎÊýµÄ¶¨Òå:
ÈÕÆÚ/ʱ¼äת»»
ÒÔÏÂÈÕÆÚºÍʱ¼äת»»µÄºó׺×Ö·ûÊÇΪ 't' ºÍ 'T' ת»»¶¨ÒåµÄ¡£ÕâЩÀàÐÍÏàËÆÓÚµ«²»ÍêÈ«µÈͬÓÚÄÇЩÓÉ GNU date ºÍ POSIX strftime(3c) ¶¨ÒåµÄÀàÐÍ¡£ÌṩÆäËûת»»ÀàÐÍÊÇΪÁË·ÃÎÊÌض¨ÓÚ Java µÄ¹¦ÄÜ£¨È罫 'L' ÓÃ×÷ÃëÖеĺÁÃ룩¡£
ÒÔÏÂת»»×Ö·ûÓÃÀ´¸ñʽ»¯Ê±¼ä£º
'H' 24 СʱÖƵÄСʱ£¬±»¸ñʽ»¯Îª±ØҪʱ´øÇ°µ¼ÁãµÄÁ½Î»Êý£¬¼´ 00 - 23¡£
'I' 12 СʱÖƵÄСʱ£¬±»¸ñʽ»¯Îª±ØҪʱ´øÇ°µ¼ÁãµÄÁ½Î»Êý£¬¼´ 01 - 12¡£
'k' 24 СʱÖƵÄСʱ£¬¼´ 0 - 23¡£
'l' 12 СʱÖƵÄСʱ£¬¼´ 1 - 12¡£
'M' СʱÖеķÖÖÓ£¬±»¸ñʽ»¯Îª±ØҪʱ´øÇ°µ¼ÁãµÄÁ½Î»Êý£¬¼´ 00 - 59¡£
'S' ·ÖÖÓÖеÄÃ룬±»¸ñʽ»¯Îª±ØҪʱ´øÇ°µ¼ÁãµÄÁ½Î»Êý£¬¼´ 00 - 60 £¨"60" ÊÇÖ§³ÖÈòÃëËùÐèµÄÒ»¸öÌØÊâÖµ£©¡£
'L' ÃëÖеĺÁÃ룬±»¸ñʽ»¯Îª±ØҪʱ´øÇ°µ¼ÁãµÄÈýλÊý£¬¼´ 000 - 999¡£
'N' ÃëÖеĺÁ΢Ã룬±»¸ñʽ»¯Îª±ØҪʱ´øÇ°µ¼ÁãµÄ¾ÅλÊý£¬¼´ 000000000 - 999999999¡£
'p' Ìض¨ÓÚÓïÑÔ»·¾³µÄ ÉÏÎç»òÏÂÎç ±ê¼ÇÒÔСдÐÎʽ±íʾ£¬ÀýÈç "am" »ò "pm"¡
Ïà¹ØÎĵµ£º
package edu.zzu.jdbc.Test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import com.ambow.jdbc.entity.Student;
public class TestDBConn{
public static void main(String args[]){
Str ......
javaÖÐʹÓöþά Êý×é
ognNf_v
public class Array2D...{
m@EvM)y0e2r
s
public static void main(String[] args)...{JAVAÖÐÎÄÕ¾ÉçÇøÃÅ»§ ~j!lSR^ z5bR5O
int myInt[][]=new int[5][10];
@XH3ao\
  ......
byte a=112,ÓóÌÐòʵÏÖ£¬½«ÆäÑ»·×óÒÆÈýλºÍÓÒÒÆÈýλ¡£
112µÄ¶þ½øÖÆÔÂë:0111 0000
112Ñ»·×óÒÆ3λºóµÄ¶þ½øÖÆÂë:1000 0011
112Ñ»·ÓÒÒÆ3λºóµÄ¶þ½øÖÆÂë:0000 1110
ÏȽ«Ñ»·×óÒƵijÌÐò´úÂë¸æËß´ó¼Ò:
public class TestCircle{
public static void main(String args[]){
byte x=112;
& ......
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
public class DealFile {
/**
* ɾ³ýÎļþ
......