private static void outPrintln(PrintStream out, String msg) { out.println(Calendar.getInstance().getTime().toString() + " " + CLASS_INFO + " " + msg); } }
@Override public String toString() { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(timestamp); return "[" + calendar.getTime().toString() + "] " + location + File.separator + name; } }
// **** YOUR CODE **** BEGIN **** long ts = System.currentTimeMillis(); Date localTime = new Date(ts); String format = "yyyy/MM/dd HH:mm:ss"; SimpleDateFormat sdf = new SimpleDateFormat(format); // Convert Local Time to UTC (Works Fine) sdf.setTimeZone(TimeZone.getTimeZone("UTC")); Date gmtTime = new Date(sdf.format(localTime)); System.out.println("Local:" + localTime.toString() + "," + localTime.getTime() + " --> UTC time:" + gmtTime.toString() + "," + gmtTime.getTime()); // **** YOUR CODE **** END **** // Convert UTC to Local Time Date fromGmt = new Date(gmtTime.getTime() + TimeZone.getDefault().getOffset(localTime.getTime())); System.out.println("UTC time:" + gmtTime.toString() + "," + gmtTime.getTime() + " --> Local:" + fromGmt.toString() + "-" + fromGmt.getTime());
SimpleDateFormat daf2 = new SimpleDateFormat(); System.out.println(); Date maxdate = maxDate[i][x]; message.append( BaseMessages.getString( PKG, "TextFileCSVImportProgressDialog.Info.DateMinValue", mindate.toString() ) ); message.append( BaseMessages.getString( PKG, "TextFileCSVImportProgressDialog.Info.DateMaxValue", maxdate.toString() ) ); Date md = daf2.parse( minstr[i] ); message.append( BaseMessages.getString( PKG, "TextFileCSVImportProgressDialog.Info.DateExample", Const .getDateFormats()[x], minstr[i], md.toString() ) ); } catch ( Exception e ) { if ( log.isDetailed() ) {
private String getDateString() { if( format == null ){ try{ format = new SimpleDateFormat( DATE_TEMPLET, Locale.ENGLISH ); }catch( Exception e ){} } return ( format == null ? new Date().toString() : format.format( new Date() ) ); }
public static void main(String[] args) { TimeZone localTimezone = Calendar.getInstance().getTimeZone(); TimeZone gmtTimezone = TimeZone.getTimeZone("GMT"); TimeZone estTimezone = TimeZone.getTimeZone("EST"); Date time = new Date(); System.out.println("local time :" + DateUtil.getDateDisplayString(localTimezone, time)); System.out.println("GMT time :" + DateUtil.getDateDisplayString(gmtTimezone, time)); System.out.println("EST time :" + DateUtil.getDateDisplayString(estTimezone, time)); //Test next run time. Expects interval and schedule as arguments if (args.length == 2) { System.out.println("Next run time: " + DateUtil.getNextRunTime(IntervalType.getIntervalType(args[0]), args[1], "GMT", time).toString()); } }
public static void main(String[] args) throws IOException { // Use the factory to get Cex.IO exchange API using default settings Exchange exchange = ExchangeFactory.INSTANCE.createExchange(AbucoinsExchange.class.getName()); // Interested in the public market data feed (no authentication) MarketDataService marketDataService = exchange.getMarketDataService(); // Get the latest order book data for GHs/BTC OrderBook orderBook = marketDataService.getOrderBook(CurrencyPair.BTC_USD); System.out.println( "Current Order Book size for BTC/USD: " + (orderBook.getAsks().size() + orderBook.getBids().size())); System.out.println("First Ask: " + orderBook.getAsks().get(0).toString()); System.out.println("First Bid: " + orderBook.getBids().get(0).toString()); System.out.println("Timestamp: " + orderBook.getTimeStamp().toString()); // System.out.println(orderBook.toString()); } }
c.set(Calendar.MINUTE, 58); c.set(Calendar.SECOND, 15); Date d = c.getTime(); System.out.println("Start point: " + d.toString()); System.out.println("Nearest whole minute: " + toNearestWholeMinute(d)); System.out.println("Nearest whole hour: " + toNearestWholeHour(d)); return c.getTime(); c.set(Calendar.SECOND, 0); return c.getTime();
public static void main(String[] args) throws ParseException { GregorianCalendar gcal = new GregorianCalendar(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd"); Date start = sdf.parse("2010.01.01"); Date end = sdf.parse("2010.01.14"); gcal.setTime(start); while (gcal.getTime().before(end)) { gcal.add(Calendar.DAY_OF_YEAR, 1); System.out.println( gcal.getTime().toString()); } }
import java.util.*; import java.text.*; class Test { public static void main(String[] args) { Date thisDate = null; try { thisDate = (new SimpleDateFormat("MM/dd/yyyy")).parse(Calendar.getInstance().getTime().toString()); } catch (Exception e) { e.printStackTrace(); } } }
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = sdf.parse("2009-08-19 12:00:00"); System.out.print(date.toString());
SimpleDateFormat hackFormatter = new SimpleDateFormat(recentDateFormat.toPattern() + " yyyy", recentDateFormat.getDateFormatSymbols()); hackFormatter.setLenient(false); throw new ParseException( "Timestamp '"+timestampStr+"' could not be parsed using a server time of " +serverTime.getTime().toString(), pp.getErrorIndex());
/** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { String path = "./tmpdata/FNLPDATA"; String toPath = "./tmpdata/FNLPDATA/data-pos.txt"; trans(path, toPath); System.out.println(new Date().toString()); System.out.println("Done!"); } static void trans(String path, String toPath) throws IOException,
private static void println(PrintStream out, String msg) { out.println(Calendar.getInstance().getTime().toString() + " " + CLASS_INFO + " " + msg); }
SimpleDateFormat daf2 = new SimpleDateFormat(); System.out.println(); Date maxdate = maxDate[i][x]; message.append( BaseMessages.getString( PKG, "TextFileCSVImportProgressDialog.Info.DateMinValue", mindate.toString() ) ); message.append( BaseMessages.getString( PKG, "TextFileCSVImportProgressDialog.Info.DateMaxValue", maxdate.toString() ) ); message.append( BaseMessages.getString( PKG, "TextFileCSVImportProgressDialog.Info.DateExample", Const.getDateFormats()[x], minstr[i], md.toString() ) ); } catch ( Exception e ) { if ( log.isDetailed() ) {
/** * Returns a default formatted string with fields separated by "," * * @return a default formatted string with fields separated by "," */ @Override public String toString() { return new Date(ts).toString() + "," + component + "," + String.valueOf(task) + "," + (messageId == null ? "" : messageId.toString()) + "," + values.toString(); } }