public static void main(String[] args){
Date localRecvTime = new Date();
DateFormat converter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
converter.setTimeZone(TimeZone.getTimeZone("GMT"));
String ConvertedDate =converter.format(localRecvTime);
System.out.println(ConvertedDate.length());
//above statement will print 24
byte[] dateInBytes=ConvertedDate.getBytes();
System.out.println(dateInBytes.length);
//above statement will also print 24
}
上面的代码工作正常。但我想array(ie. byte[] dateInBytes)
根据我的要求将字节的大小限制为 4 个字节。有可能这样做吗?