-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DEL] Eliminar dependencias projecto Tools
- Loading branch information
1 parent
d4088c7
commit 308672c
Showing
11 changed files
with
141 additions
and
116 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
app/src/main/java/es/incaser/apps/stockcontrol/Tools.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
package es.incaser.apps.stockcontrol; | ||
|
||
import android.widget.EditText; | ||
|
||
import java.text.DecimalFormat; | ||
import java.text.ParseException; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Calendar; | ||
import java.util.Date; | ||
|
||
/** | ||
* Created by sergio on 2/10/14. | ||
*/ | ||
public class Tools { | ||
public static String UUID_EMPTY = "00000000-0000-0000-0000-000000000000"; | ||
|
||
public static float getNumber(String text) { | ||
if (text == null) { | ||
return 0; | ||
} else if (text.length() == 0) { | ||
return 0; | ||
} else if (text.matches(".*\\\\D+.*")) { | ||
return 0; | ||
} else { | ||
//TODO Controlar separador de miles | ||
return Float.valueOf(text.replace(",", ".")); | ||
} | ||
} | ||
|
||
public static float getNumber(EditText txt) { | ||
return getNumber(txt.getText().toString()); | ||
} | ||
|
||
public static String importeStr(Float importe) { | ||
DecimalFormat nf = new DecimalFormat(); | ||
nf.applyPattern("#0.00"); | ||
return nf.format(importe); | ||
} | ||
|
||
public static String importeStr(String importe) { | ||
return importeStr(getNumber(importe)); | ||
} | ||
|
||
|
||
public static int getInt(String text) { | ||
return Math.round(getNumber(text)); | ||
} | ||
|
||
public static int getInt(EditText txtView) { | ||
return getInt(txtView.getText().toString()); | ||
} | ||
|
||
public static String enteroStr(Integer x) { | ||
return x.toString(); | ||
} | ||
|
||
public static String importeStr(EditText txt) { | ||
return importeStr(txt.getText().toString()); | ||
} | ||
|
||
public static String getToday() { | ||
return getToday("yyyy-MM-dd 00:00:00.0"); | ||
} | ||
|
||
public static String getToday(String format) { | ||
Date date = Calendar.getInstance().getTime(); | ||
SimpleDateFormat sdf = new SimpleDateFormat(format); | ||
return sdf.format(date); | ||
} | ||
|
||
public static String millis2String(Long miliseconds) { | ||
Calendar date = Calendar.getInstance(); | ||
date.setTimeInMillis(miliseconds); | ||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); | ||
return sdf.format(date.getTime()); | ||
} | ||
|
||
// public static String getActualHour(){ | ||
// Date date = Calendar.getInstance().getTime(); | ||
// SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss"); | ||
// return sdf.format(date); | ||
// } | ||
|
||
public static double getActualHour() { | ||
Date date = Calendar.getInstance().getTime(); | ||
return getHourFractionDay(date.getTime()); | ||
} | ||
|
||
public static double getHourFractionDay(long timelong) { | ||
double milisecondsDay = 86400000.00; | ||
return (timelong % (milisecondsDay)) / milisecondsDay; | ||
} | ||
|
||
public static String getTimeStamp() { | ||
Date date = Calendar.getInstance().getTime(); | ||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.S"); | ||
return sdf.format(date); | ||
} | ||
|
||
public static Date str2date(String myTimestamp, String strFormat) { | ||
SimpleDateFormat formato = new SimpleDateFormat(strFormat); | ||
Date convertedDate = null; | ||
try { | ||
convertedDate = formato.parse(myTimestamp); | ||
} catch (ParseException e) { | ||
e.printStackTrace(); | ||
} | ||
return convertedDate; | ||
} | ||
|
||
public static Date str2date(String myTimestamp) { | ||
return str2date(myTimestamp, "yyyy-MM-dd HH:mm:ss.S"); | ||
} | ||
|
||
public static String date2str(Date date, String strFormat) { | ||
SimpleDateFormat formato = new SimpleDateFormat(strFormat); | ||
return formato.format(date); | ||
} | ||
|
||
public static String date2str(Date date) { | ||
return date2str(date, "dd-MM-yyyy 00:00:00.0"); | ||
} | ||
|
||
public static String dateStr2str(String date) { | ||
return date2str(str2date(date), "dd/MM/yyyy"); | ||
} | ||
|
||
public static String date2Sql(String date){ | ||
return "CONVERT(DATETIME,'" + date + "', 102)"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
include ':app',':tools' | ||
include ':app' |
This file was deleted.
Oops, something went wrong.