public static String time( long millis ) { return time( millis, DEFAULT_TIME_ZONE ); }
public static String time() { return time( DEFAULT_TIME_ZONE ); }
public static String time( Date date ) { return time( date, DEFAULT_TIME_ZONE ); }
public static String time( TimeZone timeZone ) { return time( new Date(), timeZone ); }
public static String time( long millis, TimeZone timeZone ) { return time( new Date( millis ), timeZone ); }
private static String fileName( String category, Pair<Long,String> pid ) { return time().replace( ':', '_' ).replace( '.', '_' ) + "-" + category + "-" + pid.first() + "-" + pid.other(); } }
@Test void dateTime() throws Exception { // Date long timeWithDate = System.currentTimeMillis(); String dateAsString = Format.date( timeWithDate ); assertEquals( timeWithDate, new SimpleDateFormat( Format.DATE_FORMAT ).parse( dateAsString ).getTime() ); // Time String timeAsString = Format.time( timeWithDate ); assertEquals( timeWithDate, translateToDate( timeWithDate, new SimpleDateFormat( Format.TIME_FORMAT ).parse( timeAsString ).getTime(), Format.DEFAULT_TIME_ZONE ) ); }
@Test void dateTimeWithTimeZone() throws Exception { String zoneOffset = "+03:00"; TimeZone zone = TimeZone.getTimeZone( "GMT" + zoneOffset ); // Date String asString = Format.date( zone ); assertTrue( asString.endsWith( withoutColon( zoneOffset ) ) ); long timeWithDate = new SimpleDateFormat( Format.DATE_FORMAT ).parse( asString ).getTime(); asString = Format.date( timeWithDate, zone ); assertTrue( asString.endsWith( withoutColon( zoneOffset ) ) ); assertEquals( timeWithDate, new SimpleDateFormat( Format.DATE_FORMAT ).parse( asString ).getTime() ); asString = Format.date( new Date( timeWithDate ), zone ); assertTrue( asString.endsWith( withoutColon( zoneOffset ) ) ); assertEquals( timeWithDate, new SimpleDateFormat( Format.DATE_FORMAT ).parse( asString ).getTime() ); // Time asString = Format.time( timeWithDate, zone ); assertEquals( timeWithDate, translateToDate( timeWithDate, new SimpleDateFormat( Format.TIME_FORMAT ).parse( asString ).getTime(), zone ) ); asString = Format.time( new Date( timeWithDate ), zone ); assertEquals( timeWithDate, translateToDate( timeWithDate, new SimpleDateFormat( Format.TIME_FORMAT ).parse( asString ).getTime(), zone ) ); }
public static String time( Date date ) { return time( date, DEFAULT_TIME_ZONE ); }
private static String informativeTimestamp( long timestamp ) { return time( timestamp ) + "/" + timestamp; } }
public static String time() { return time( DEFAULT_TIME_ZONE ); }
public static String time( long millis ) { return time( millis, DEFAULT_TIME_ZONE ); }
public static String time( TimeZone timeZone ) { return time( new Date(), timeZone ); }
public static String time( long millis, TimeZone timeZone ) { return time( new Date( millis ), timeZone ); }