1 28 29 package com.caucho.config.functions; 30 31 import com.caucho.log.Log; 32 import com.caucho.server.util.CauchoSystem; 33 import com.caucho.util.Alarm; 34 import com.caucho.util.L10N; 35 import com.caucho.util.QDate; 36 import com.caucho.util.Sprintf; 37 38 import java.util.Calendar ; 39 import java.util.Date ; 40 import java.util.logging.Logger ; 41 42 45 public class FmtFunctions { 46 static protected final Logger log = Log.open(FmtFunctions.class); 47 static final L10N L = new L10N(FmtFunctions.class); 48 49 static private QDate _calendar = new QDate(true); 50 51 public FmtFunctions() 52 { 53 } 54 55 58 static public String timestamp(String format) 59 { 60 long now; 61 62 if (CauchoSystem.isTesting()) 63 now = Alarm.getCurrentTime(); 64 else 65 now = System.currentTimeMillis(); 66 67 return timestamp(format,now); 68 } 69 70 static protected String timestamp(String format, long t) 71 { 72 return _calendar.formatLocal(t, format); 73 } 74 75 public static String timestamp(String format, Date date) 76 { 77 return timestamp(format,date.getTime()); 78 } 79 80 public static String timestamp(String format, Calendar date) 81 { 82 return timestamp(format,date.getTimeInMillis()); 83 } 84 85 public static String timestamp(String format, QDate date) 86 { 87 return date.format(format); 88 } 89 90 public static String sprintf(String format, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9) 91 { 92 return Sprintf.sprintf(format, new Object [] { arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 } ); 93 } 94 95 public static String sprintf(String format, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8) 96 { 97 return Sprintf.sprintf(format, new Object [] { arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 } ); 98 } 99 100 public static String sprintf(String format, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7) 101 { 102 return Sprintf.sprintf(format, new Object [] { arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7 } ); 103 } 104 105 public static String sprintf(String format, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6) 106 { 107 return Sprintf.sprintf(format, new Object [] { arg0, arg1, arg2, arg3, arg4, arg5, arg6 } ); 108 } 109 110 public static String sprintf(String format, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) 111 { 112 return Sprintf.sprintf(format, new Object [] { arg0, arg1, arg2, arg3, arg4, arg5 } ); 113 } 114 115 public static String sprintf(String format, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4) 116 { 117 return Sprintf.sprintf(format, new Object [] { arg0, arg1, arg2, arg3, arg4 } ); 118 } 119 120 public static String sprintf(String format, Object arg0, Object arg1, Object arg2, Object arg3) 121 { 122 return Sprintf.sprintf(format, new Object [] { arg0, arg1, arg2, arg3 } ); 123 } 124 125 public static String sprintf(String format, Object arg0, Object arg1, Object arg2) 126 { 127 return Sprintf.sprintf(format, new Object [] { arg0, arg1, arg2 } ); 128 } 129 130 public static String sprintf(String format, Object arg0, Object arg1) 131 { 132 return Sprintf.sprintf(format, new Object [] { arg0, arg1 } ); 133 } 134 135 public static String sprintf(String format, Object arg0) 136 { 137 return Sprintf.sprintf(format, new Object [] { arg0 } ); 138 } 139 } 140 141 | Popular Tags |